Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path to file on a Mac: FileNotFoundException

Tags:

java

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?

like image 589
LuxuryMode Avatar asked May 12 '11 00:05

LuxuryMode


1 Answers

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");
like image 113
BoltClock Avatar answered Sep 19 '22 13:09

BoltClock