File f = new File(System.getProperty("user.home/Downloads"));
Run Code Online (Sandbox Code Playgroud)
为什么这段代码会出现NPE错误?
我知道它返回null,但目录在那里......
因为
System.getProperty("user.home/Downloads")
Run Code Online (Sandbox Code Playgroud)
返回null,因为没有这样的关键设置user.home/Downloads
你可能正在寻找
final String fileName = System.getProperty("user.home") + File.saperator + "Downloads";
File f = new File(fileName);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93 次 |
| 最近记录: |