我想为我要读取的文件设置路径,而不必指定根目录或整个路径。像这样:File file = new File("Text01.txt");
或者Path file = Paths.get("Accounts.txt");
代替:Path file = Paths.get("C:\\Users\\B_HITMAN\\Documents\\NetBeansProjects\\BankAccountGUI\\src\\bankaccountgui\\Accounts.txt");
我什至尝试将文件放在netbeans的构建目录中,但它也不起作用。它显示了这条消息:
Exception in thread "main" java.io.FileNotFoundException: Text01.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at assignment01.Assignment01.main(Assignment01.java:19)
Java Result: 1