Name: vi73552 Date: 04/21/99
the canonical pathname string for the empty pathname
object file=new File("") is computed using the system property
user.dir, but NOT the access to the underlying file, at least
when calling the method list()
So:
//----------- UserDirTest
package bugs;
import java.io.*;
public class UserDirTest {
public static void main(String[] args) throws IOException {
File dir= new File("");
System.out.println("User directory is: "+dir.getCanonicalPath());
System.out.println("Content is:");
String[] names= dir.list();
for(int i= 0;i<names.length;i++) {
System.out.println("\t"+names[i]);
}
}
}
produces something like:
C:\Java\Projects\classes>java -Djava.compiler=NONE bugs.UserDirTest
User directory is: C:\Java\Projects\classes
Content is:
Exception in thread "main" java.lang.NullPointerException:
at bugs.UserDirTest.main(UserDirTest.java:18)
instead of:
User directory is: C:\Java\Projects\classes
Content is:
bugs
(Review ID: 56975)
======================================================================
- relates to
-
JDK-4271380 File.list() needs to be restored to old behavior.
-
- Resolved
-
-
JDK-4271369 (spec) File.list() should document behaviour if path is the empty string
-
- Open
-