我使用以下方法下载了一个mp3文件:
http://online1.tingclass.com/lesson/shi0529/43/32.mp3,
但是我遇到了以下错误:
java.io.FileNotFoundException: http:\online1.tingclass.com\lesson\shi0529\43\32.mp3(文件名、目录名或卷标语法不正确)
如果我手动从浏览器中执行该操作,则文件是存在的,我想知道为什么它没有起作用,以及正确的操作方式是什么?
弗兰克
public static void Copy_File(String From_File,String To_File)
{
try
{
FileChannel sourceChannel=new FileInputStream(From_File).getChannel();
FileChannel destinationChannel=new FileOutputStream(To_File).getChannel();
sourceChannel.transferTo(0,sourceChannel.size(),destinationChannel);
// or
// destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
sourceChannel.close();
destinationChannel.close();
}
catch (Exception e) { e.printStackTrace(); }
}
如果我手动从浏览器中执行该操作,则文件是存在的,我想知道为什么它没有起作用,以及正确的操作方式是什么?
弗兰克