我确定我在这里遗漏了一些基本的东西。我正在尝试在我的驱动器上创建一个新文件,但出现错误:
Exception in thread "main" java.io.FileNotFoundException: C:\ProgramData\msena\test.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileReader.<init>(FileReader.java:55)
at net.meosoft.relatetoit.core.HibernateSessionFactory.main(HibernateSessionFactory.java:89)
我目前的代码是:
final File file = new File("C:\\ProgramData\\uname2\\test.txt");
final BufferedReader in = new BufferedReader(new FileReader(file));
while(in.ready()) {
System.out.println(in.readLine());
}
in.close();
目前有什么问题?我只想阅读,即使它在那里(所以应该制作文件)。