<Swing Dev> [9] Review request for 8041694: JFileChooser removes trailing spaces in the selected directory name
Anton Litvinov
anton.litvinov at oracle.com
Wed May 11 14:24:44 UTC 2016
Hello Sergey,
Particularly on MS Windows OS "File" object containing trailing spaces
in the directory name returned from getSelectedFile(), probably could
not be used anyhow similarly as it is now, when "JFileChooser" returns
"File" with trimmed spaces from the right of the directory name, since
the trimmed directory name does not equal the actual directory name in
the file system. But on Linux OS "File" object with not trimmed
directory name can be successfully used for "File" operations like
"File.exists()", while "File" with trimmed directory name will be
treated as not existent.
For example "File.exists()" method returns "false" for both trimmed and
not trimmed names in "File" object on MS Windows OS, if in the file
system the corresponding directory contains spaces in the end of its
name. For this particular case ("File.exists()") I already filed a
separate bug in Java Core Libraries area
(https://bugs.openjdk.java.net/browse/JDK-8156657).
Though currently Java Core Libraries do not support directory and file
names ending with spaces on MS Windows OS, I still think that it is
incorrect that "JFileChooser" modifies the real name of the directory or
file by removing trailing spaces from its name.
Thank you,
Anton
On 5/11/2016 4:54 PM, Sergey Bylokhov wrote:
> On 11.05.16 16:47, Anton Litvinov wrote:
>> The method "java.nio.file.Files.createDirectory(Path dir,
>> FileAttribute<?>... attrs)" cannot be used for this purpose also,
>> because "java.nio.file.Path" cannot be constructed for the directory
>> name ending with spaces and "java.io.File.toPath()" throws the exception
>> "java.nio.file.InvalidPathException: Trailing char < > at index N:
>> <DIRECTORY_PATH>".
>
> Then how the File which was returned from getSelectedFile() can be
> used(what operations will be allowed?) by the application if such
> files are unsupported by the corelib?
>
>>
>> It is possible to create a directory with such a name from the shell
>> script on MS Windows OS, therefore I decided to use the shell script for
>> this regression test.
>
> Note sure that the case for windows correct:
> Windows_95 | Windows_98 | Windows_NT | Windows_ME
>
>
More information about the swing-dev
mailing list