為什么程序總是提醒文件不存在? 文件的確是存在的
public static void copyFileByBuffer(File srcFile,File desFile) throws IOException{
if(!srcFile.exists()){
throw new IllegalArgumentException("The file is not exists.");
}
if(!desFile.isFile()){
throw new IllegalArgumentException("This name not target a file");
}
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(desFile));
int c;
while((c=bis.read())!=-1){
bos.write(c);
bos.flush();
}
bis.close();
bos.close();
}
public static void main(String[] args) throws IOException {
// IOunit.Outputtest();
// IOunit.FileCopy(new File("e:\\word.txt"), new File("e:\\word1.txt"));
IOunit.copyFileByBuffer(new File("E:\\迅雷下載\\weixin6327android880.apk"),
new File("E:\\迅雷下載\\XMPSetupLite-xl81.exe"));
}
錯誤信息:
Exception in thread "main" java.lang.IllegalArgumentException: This name not target a file
at com.wfu.IOunit.copyFileByBuffer(IOunit.java:85)
at com.wfu.IOunit.main(IOunit.java:102)
2016-10-13
apk不是文件,我是這么認(rèn)為的