java - Why the JVM is not able to detect some invalid paths -
java - Why the JVM is not able to detect some invalid paths -
i want know why jvm
doesn't throw exception when asked create invalid path such "c:invalidpath
". illustration :
public static void main(string[] args) { file f = new file("c:invalidpath"); f.mkdir(); }
the previous illustration create folder named "invalidpath" in current folder. think not normal .
this not jvm's fault or responsibility.
it underlying filesystem convert path specification (i.e. string) actual logical files name represents. jvm passes through string filesystem, determines how handle it.
so real question "why ntfs [assuming that's you're using] interpret 'c:invalidpath' creating file in current directory?". , reason simply, that's how paths defined filesystem.
from the documentation:
if file name begins disk designator not backslash after colon, interpreted relative path current directory on drive specified letter. note current directory may or may not root directory depending on set during recent "change directory" operation on disk. examples of format follows:
"c:tmp.txt" refers file named "tmp.txt" in current directory on drive c. java
Comments
Post a Comment