FULL PRODUCT VERSION :
JDK 1.9.0 b116
ADDITIONAL OS VERSION INFORMATION :
64-bit MS Windows 7 OS
A DESCRIPTION OF THE PROBLEM :
The method "java.io.File.exists()" called on "java.io.File" object constructed from the absolute path to existing in the file system directory or file, whose name ends with space characters, for example "Directory1 ", "File1 ", "File2.txt ", always returns "false" value.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the specified below test case.
2. Create in the file system a directory or a file, whose name ends with any number of space characters.
3. Run the compiled test case with a tested JDK and specify the absolute path to the created in the step #2 directory or file as the argument for the test case. For example:
"C:\Program Files (x86)\Java\jre-9\bin\java" FileNameEndingWithSpacesIsNotSupported "C:\Users\TestUser\AppData\Local\Temp\Directory1 "
---------- BEGIN SOURCE ----------
import java.io.File;
public class FileNameEndingWithSpacesIsNotSupported {
public static void main(String[] args) {
if (args.length > 0) {
File file = new File(args[0]);
System.out.println(String.format("File '%s' exists()='%b'", file, file.exists()));
}
}
}
---------- END SOURCE ----------
JDK 1.9.0 b116
ADDITIONAL OS VERSION INFORMATION :
64-bit MS Windows 7 OS
A DESCRIPTION OF THE PROBLEM :
The method "java.io.File.exists()" called on "java.io.File" object constructed from the absolute path to existing in the file system directory or file, whose name ends with space characters, for example "Directory1 ", "File1 ", "File2.txt ", always returns "false" value.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the specified below test case.
2. Create in the file system a directory or a file, whose name ends with any number of space characters.
3. Run the compiled test case with a tested JDK and specify the absolute path to the created in the step #2 directory or file as the argument for the test case. For example:
"C:\Program Files (x86)\Java\jre-9\bin\java" FileNameEndingWithSpacesIsNotSupported "C:\Users\TestUser\AppData\Local\Temp\Directory1 "
---------- BEGIN SOURCE ----------
import java.io.File;
public class FileNameEndingWithSpacesIsNotSupported {
public static void main(String[] args) {
if (args.length > 0) {
File file = new File(args[0]);
System.out.println(String.format("File '%s' exists()='%b'", file, file.exists()));
}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-4923243 Space chars at end of directory name confuses java.io.File.list()Shou
-
- Resolved
-
-
JDK-8041694 JFileChooser removes trailing spaces in the selected directory name
-
- Resolved
-
-
JDK-8190546 File.toPath() reject directory names with trailing space
-
- Closed
-