java - Why the JVM is not able to detect some invalid paths -


I want to know why why JVM does not make any exception when it says to create it Gets an invalid path such as " C: invalid text ". For example:

  public static zero main (string [] args) {file f = new file ("C: invalid path"); F.mkdir (); }  

Previous example in the current folder, create a folder named "invalidPath". I think this is not normal.

This is not the fault or responsibility of JVM.

It depends on the underlying file system to change the path specification (i.e. string) in the actual logical files that represent the name. JVM simply passes through this string in the file system, which determines how it is.

So the real question is "Why NTFS [assuming what you are using] explain 'C: Invalid Path' to make that file in existing directory ? 'And the reason for this is how the paths for this file system have been defined.

From:

If any file name starts with only one disc designator But after the backslash, not the colon, it is present on the drive with the specified letter The directory is interpreted as a relative path. Note that the existing directory can not be root directory based on the most recent "change directory" that was set during that operation, or may be The examples of this format are as follows:

  • "C: tmp.txt" refers to a file named "tmp.txt" in the current directory on drive C.

Comments