0
votes

Eclipse Luna doesn't see the mapped Network drives! Obviously I am able to read any file on the mapped drive.

Here is my test:

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);
}

running as a Java application I got:

Exception in thread "main" java.lang.NullPointerException
at variousTest.fileFinder.main(fileFinder.java:28)

I can confirm you that the drive has a big list of folder inside it.

Operating System: Windows 7 Professional SP1

UPDATE I - 10 September:

i tried to run the program outside eclipse, and it i am bewildered about the result, in fact i got this exception:

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)

UPDATE II - 10 September:

above exception (update I) was raised becouse of rights. The program runs correctly using the directory C:\Users\username\Desktop

1
Run it from a command line, first trying O: and dir. This should take care of authorization being done for the Windows user. Then listFiles should no longer return null. (No solution, but to see whether this helps.) - Joop Eggen
@greg-449 Line 28 is the SystemOut. - Robdll
@JoopEggen "dir O:" return the full list of folder inside the O: drive in the command prompt - Robdll

1 Answers

0
votes

Windows usually requires administrator rights to access the root of C:. Can you try writing to your Desktop folder? The path would then be C:\Users\<user>\Desktop\test.txt.