Android 从网页中复制一个应用程序文件
我已经做了一个应用程序,必须从一个网页复制一个文件,以下代码不做的工作,它无法找到该文件Android 从网页中复制一个应用程序文件,android,Android,我已经做了一个应用程序,必须从一个网页复制一个文件,以下代码不做的工作,它无法找到该文件 File ekstern = new File("http://192.168.13.40/cache.manifest"); copyFile(ekstern, intern); 以及copyFile方法: public static void copyFile(File in, File out) throws IOException { FileChannel inChan
File ekstern = new File("http://192.168.13.40/cache.manifest");
copyFile(ekstern, intern);
以及copyFile方法:
public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new
FileInputStream(in).getChannel();
FileChannel outChannel = new
FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(),
outChannel);
}
catch (IOException e) {
throw e;
}
finally {
if (inChannel != null) inChannel.close();
if (outChannel != null) outChannel.close();
}
}
但是代码说这个文件不存在
使用ekster.exists()进行测试。您不能使用文件对象从网页获取内容。您必须使用HttpClient