I have made an app that have to copy a file from a webpage, the following code doesn't do the job, it can't find the file
File ekstern = new File("http://192.168.13.40/cache.manifest");
copyFile(ekstern, intern);
and the copyFile method:
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();
}
}
But the code says that the file doesn't exists
testing with ekstern.exists()
You can't use File object to get something from a webpage. You have to use an HttpClient
精彩评论