I'm willing to save a file in the user's "My Documents" folder.
I tried getting the location like this :
System.getenv("USERPROFILE") + "\\My Documents\\"
Then, I realized this wouldn't work in a system where the language is set to another language, french for example.
Is there another way of getting the "My Documents" folder efficiently?
Regarding performance, this is faster than using JFileChooser
:
FileSystemView.getFileSystemView().getDefaultDirectory().getPath()
In my PC, JFileChooser
approach needed 300ms, and calling FileSystemView
directly needed less than 100ms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With