作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我似乎无法让文件 IO 在 netbeans 中工作
public static void main(String[] args) throws IOException
{
System.out.println("File Location: "+ System.getProperty("myFile.txt"));
//File file = new File("myFile.txt");
}
我对此有一个异常(exception)。
Exception in thread "main" java.lang.NullPointerException
并输出:
File Location: null
没有System.getProperty
,我得到FileNotFoundException
java.io.FileNotFoundException: myFile.txt (The system cannot find the file specified)
该文件本身位于项目的源目录中,并且还显示在 IDE 中的 Source Packages > myproject> myFile.txt 下
找不到该文件的任何原因或任何建议?
谢谢
最佳答案
如果您像“myFile.txt”这样调用文件,则应将其放置在此处
MyProject (project root)
myFile.txt
src
关于java - Netbeans 文件 I/O FileNotFound/FileLocation Null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19748353/
我是一名优秀的程序员,十分优秀!