【发布时间】:2014-07-30 11:55:22
【问题描述】:
你能告诉我如何从服务器下载文件吗?我收到错误填充未找到错误?
07-30 17:10:28.849: W/System.err(14900): java.io.FileNotFoundException: /testnaveen: open failed: EROFS (Read-only file system)
07-30 17:10:28.849: W/System.err(14900): at libcore.io.IoBridge.open(IoBridge.java:409)
07-30 17:10:28.849: W/System.err(14900): at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
07-30 17:10:28.849: W/System.err(14900): at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
07-30 17:10:28.849: W/System.err(14900): at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
07-30 17:10:28.849: W/System.err(14900): at com.mobilecem.atms.GlobalFunction.downloadFileFromServer(GlobalFunction.java:147)
我就是这样的
public static void downloadFileFromServer(String filename, String urlString) throws MalformedURLException, IOException
{
BufferedInputStream in = null;
FileOutputStream fout = null;
try
{
URL url = new URL(urlString);
in = new BufferedInputStream(url.openStream());
fout = new FileOutputStream(filename);
byte data[] = new byte[1024];
int count;
while ((count = in.read(data, 0, 1024)) != -1)
{
fout.write(data, 0, count);
System.out.println(count);
}
}
finally
{
if (in != null)
in.close();
if (fout != null)
fout.close();
}
System.out.println("Done");
}
我两种方式都调用,但是为什么会出现同样的错误?
GlobalFunction.downloadFileFromServer("test", "http://www.example.com/inputParameters.js");
GlobalFunction.downloadFileFromServer( new File(Activity.this.getFilesDir(),"www").getAbsolutePath(), "url");
【问题讨论】:
-
确保您的文件不是只读的。已在您的清单中提供了 WRITE_EXTERNAL_STORAGE 权限?
-
已写入清单文件..请从服务器下载文件
-
确保你的文件名是正确的,并且上传到服务器上。
-
如果你点击喜欢,它就会上传到服务器上,因为有文件。但是文件名是什么?我什么都提
标签: android