File f = new File("c:\tmp","\foo")
creates a File with "c:\tmp\foo" as full path.
according to bug 4179128 the 2nd param should not be absolute, so it should be checked before attempting the creation of the File object.
File("\\foo").isAbsolute() returns false, according to bug 4242635 this is correct because it can not be any ambiguity in the file name in order to be absolute (i.e.: the drive letters in win).
the recommendation of bug 4179128 does not work
String absName = "c:\\tmp";
String relName = "\\foo";
File file = new File(relName);
if (file.isAbsolute()) {
file = new File(absName,relName);
}
creates a file with path "c:\\tmp\\foo" when the path should be "c:\\foo"
- relates to
-
JDK-4179128 java.io.File.isAbsolute reporting false on "\"
- Closed
-
JDK-4242635 java.io.File(File,String) produces illegal path if both parameters are absolute
- Closed