问答详情
源自:4-5 字节缓冲流

为什么程序总是提醒文件不存在? 文件的确是存在的

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)


提问者:leeu 2016-10-13 10:47

个回答

  • 慕丝0809581
    2016-10-13 11:56:35
    已采纳

    apk不是文件,我是这么认为的