Mac上文件的路径:FileNotFoundException [英] Path to file on a Mac: FileNotFoundException
问题描述
我正在使用Mac,我正在尝试在桌面上指定文件的路径。
I'm working on a mac and I'm trying to specify the path to a file on my desktop.
我这样做是这样的:文件文件=新文件(/ users / desktop / sample.json);
当我尝试运行它时,我得到了一个FileNotFoundException。
When I tried running it I got a FileNotFoundException.
如何正确指定路径?
推荐答案
Mac OS X的文件系统区分大小写。 用户
和桌面
应以大写字母开头,您的文件名也应与大小写匹配。
Mac OS X's filesystem is case sensitive. Users
and Desktop
should start with capital letters, and your filename should also match case too.
由于您正在查找桌面文件夹而不是名称为 desktop
的用户的根文件夹,因此您需要添加用户名在用户
文件夹之后。例如:
Since you're looking for your desktop folder 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");
这篇关于Mac上文件的路径:FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!