为了账号安全,请及时绑定邮箱和手机立即绑定

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

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)


正在回答

1 回答

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

0 回复 有任何疑惑可以回复我~
#1

leeu 提问者

换成一个简单的txt文件也是如此。
2016-10-14 回复 有任何疑惑可以回复我~
#2

leeu 提问者

我懂了。。。。。第二个if应该写srcFile。。。。
2016-10-14 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

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

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号