I'm working on a mac and I'm trying to specify the path to a file on my desktop.
I just did it like this: File file = new File("/users/desktop/sample.json");
When I tried running it I got a FileNotFoundException.
How do I correctly specify the path?
Since you're looking for your desktop folder in particular, and not the root folder of a user with the name "desktop", you need to add your username after the Users folder. For example:
File file = new File("/Users/LuxuryMode/Desktop/sample.json");
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