一、问题
在使用FileInputStream或FileOutputStream时会遇到如下问题1和问题2。
问题1:
java.io.FileNotFoundException: .\xxx\xxx.txt (系统找不到指定的路径。)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at com.yaohong.test.InputStreamTest.fileInputStream(InputStreamTest.java:13)
at com.yaohong.test.InputStreamTest.main(InputStreamTest.java:27)
问题2:
java.io.FileNotFoundException: .\xx\xx (拒绝访问。)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at com.yaohong.test.InputStreamTest.fileInputStream(InputStreamTest.java:13)
at com.yaohong.test.InputStreamTest.main(InputStreamTest.java:27)
二、分析
在进行分析时,我得说清楚什么时候抛拒绝访问,什么时候抛找不到指定路径。原因是这样的,在构造一个File对象时&#x