0
我正在從遠程服務器下載音頻文件,然後打算在應用程序上實際播放它之前將其保存到存儲空間。 我使用sliderbridge類來顯示進度,但是當我嘗試將其保存到存儲我得到下載完成這個錯誤:java.io.FileNotFoundException在Codenameone
java.io.FileNotFoundException
相關代碼:
public void actionPerformed(ActionEvent ae) {
final String file=_cat+".mp3";
if(FileSystemStorage.getInstance().exists(file))
{FileSystemStorage.getInstance().delete(file);};
String path="/"+file;
ConnectionRequest r = new ConnectionRequest() {
protected void postResponse() {
try{
String path1=FileSystemStorage.getInstance().getAppHomePath();
String path2=path1+"/"+file;
InputStream stream =FileSystemStorage.getInstance().openInputStream(path2);
OutputStream out = Storage.getInstance().createOutputStream(file);
Util.copy(stream, out);
Util.cleanup(stream);
Util.cleanup(out);
}
catch(Exception ex)
{ex.printStackTrace();}
}
protected void handleException(Exception err) {
Dialog.show("Network Error!!", "Are you connected to the internet? Check your connection...And Click To Start Again", "Ok", null);
overall.removeComponent(Welcome);
overall.removeComponent(sb);
overall.invalidate();
overall.revalidate();
}
};
r.setUrl("http://abcde.com/images/"+file);
r.setPost(false);
try
{
sb=new SliderBridge(r);
NetworkManager.getInstance().addToQueue(r);
overall.addComponent(Welcome);
overall.addComponent(sb);
overall.repaint();
overall.invalidate();
overall.revalidate();
}
catch (Exception ex) {
ex.printStackTrace();
}