Eclipse Luna 看不到映射的网络驱动器!显然我能够读取映射驱动器上的任何文件。
这是我的测试:
public static void main(String[] args) throws
// this part works properly
File myFile = new File("C:\\test.txt");
FileWriter fw = new FileWriter(myFile);
fw.write("test");
fw.close();
//this will throw an exception
myFile = new File("O:\\");
File[] myList = myFile.listFiles();
System.out.println(myList.length);
}
作为Java应用程序运行我得到:
Exception in thread "main" java.lang.NullPointerException
at variousTest.fileFinder.main(fileFinder.java:28)
我可以确认驱动器里面有一个很大的文件夹列表。
操作系统:Windows 7 Professional SP1
更新一 - 9 月 10 日:
我试图在 Eclipse 之外运行程序,但我对结果感到困惑,事实上我得到了这个异常:
Exception in thread "main" java.lang.FileNotFoundException: C:\test.txt (Access Denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at fileFinder.main(fileFinder.java:14)
更新二 - 9 月 10 日:
由于权利而提出了上述例外(更新I)。程序使用目录C:\Users\username\Desktop正确运行