同學們,老師們,幫幫忙哈。
package?IO; import?java.io.BufferedInputStream; import?java.io.BufferedOutputStream; import?java.io.File; import?java.io.FileInputStream; import?java.io.FileOutputStream; import?java.io.IOException; public?class?BUfferedInputStreamtest{ ?????public???void?bufferedInputStreamtest(File?srcFile,File?descFile?)? ?????throws?IOException{ ???? ?if(!srcFile.exists()){ ???? ?throw?new?IllegalArgumentException("您所輸入的文件不存在!"); ???? ?}if(!srcFile.isFile()){ ???? ?throw?new?IllegalArgumentException("您輸入的不是文件!"); ???? ?} ????????BufferedInputStream?bis=new?BufferedInputStream( ???????? new?FileInputStream(srcFile)); ????????BufferedOutputStream?bos=new?BufferedOutputStream( ???????? new?FileOutputStream(descFile)?); ???? ?int?b; ???? ?while((b=bis.read())!=-1){ ???? ?bos.write(b); ???? ?bos.flush(); ???? ?} ???? ?bis.close(); ?????????bos.close(); ?????} public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub BUfferedInputStreamtest?a=new?BUfferedInputStreamtest(); try?{ a.bufferedInputStreamtest(new?File("f:\\迅雷下載\\java錯題疑點.docx"),new File("?f:\\迅雷下載\\文件1.docx")); }?catch?(IOException?e)?{ //?TODO?Auto-generated?catch?block e.printStackTrace(); } } }
錯誤:
java.io.FileNotFoundException: ?f:\迅雷下載\文件1.docx (文件名、目錄名或卷標語法不正確。)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at IO.BUfferedInputStreamtest.bufferedInputStreamtest(BUfferedInputStreamtest.java:21)
at IO.BUfferedInputStreamtest.main(BUfferedInputStreamtest.java
我的輸出地址應該沒有錯吧
2015-08-14
?File("?f:\\迅雷下載\\文件1.docx"));
這里的文件名帶空格了·
2015-08-10
?File("?f:\\迅雷下載\\文件1.docx"));
帶空格???
2015-07-06
找不到文件,看看你的文件路徑對不對,或者你把文件夾和文件名換成英文試試