Javadoc here:
http://java.sun.com/j2se/1.4/docs/api/java/io/File.html
says:
"When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system."
How would you know what other name-separator characters are supported by the underlying system, if not separatorChar? What does that mean exactly?
For the File(File,String) constructor:
"Creates a new File instance from a parent abstract pathname and a child pathname string. [...] Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent."
[Probably "each pathname string" should read "each pathname string component".]
So the semantics of this constructor depends on the meaning of the "other name-separator characters" mentioned in the class Javadoc.
Specifically: on Windows, this works:
new File(new File("C:\\"), "dir/subdir/file")
to refer to C:\dir\subdir\file. Fine, but how would you know that this works based on the Javadoc? Or is it unspecified whether or not it will work? (Note that Windows itself does *not* accept '/' as a separator character.)
IMHO either it should fail with an explanation, or it should be documented to work. Otherwise you create an implicit dependency on an implementation detail in countless JRE-based applications, and weaken the specification of the language.
Wed Sep 11 12:48:23 MDT 2002 jg97958
http://java.sun.com/j2se/1.4/docs/api/java/io/File.html
says:
"When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system."
How would you know what other name-separator characters are supported by the underlying system, if not separatorChar? What does that mean exactly?
For the File(File,String) constructor:
"Creates a new File instance from a parent abstract pathname and a child pathname string. [...] Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent."
[Probably "each pathname string" should read "each pathname string component".]
So the semantics of this constructor depends on the meaning of the "other name-separator characters" mentioned in the class Javadoc.
Specifically: on Windows, this works:
new File(new File("C:\\"), "dir/subdir/file")
to refer to C:\dir\subdir\file. Fine, but how would you know that this works based on the Javadoc? Or is it unspecified whether or not it will work? (Note that Windows itself does *not* accept '/' as a separator character.)
IMHO either it should fail with an explanation, or it should be documented to work. Otherwise you create an implicit dependency on an implementation detail in countless JRE-based applications, and weaken the specification of the language.
Wed Sep 11 12:48:23 MDT 2002 jg97958