RFR: 6616245: NullPointerException when using JFileChooser with a custom FileView [v2]

Alexey Ivanov aivanov at openjdk.org
Mon Oct 3 11:53:24 UTC 2022


On Mon, 3 Oct 2022 11:47:20 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Since temp will be better option without creating any new directory for the test, I didn't change it (it was reused from JBS report). Any other alternative......?
>
> Why not request the path to the system temporary directory?
> 
> Temporary directory on Windows is not located in `C:\temp`. Likely this folder does not exist. You should use `TMP` or `TEMP` environment variable. Alternatively, you can use `createTempFile` from from [`java.io.File`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/File.html#createTempFile(java.lang.String,java.lang.String)) or [`java.nio.Files`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute...)) to create a file in the temp directory, its parent is the path to the temp directory.

User's home could be a better option. It's guaranteed to exist, `user.home` system property points to it. And it's a more real-life scenario.

-------------

PR: https://git.openjdk.org/jdk/pull/10485



More information about the client-libs-dev mailing list