这里没有粘贴整个代码,该行是:的PrintWriter:java.io.FileNotFoundException:在异常情况持续发生,系统找不到指定的路径
PrintWriter prtwrt = new PrintWriter(new File(directoryName+File.separator+stud.getIndex()+".txt"));
我已经咨询了互联网和书籍我对Java有所了解,并且应该遵循所有逻辑工作,但事实并非如此。有人可以解释为什么它不起作用,或者可能提出解决方案吗?
堆栈跟踪:
java.io.FileNotFoundException: students\0096-03.txt (The system cannot find the path specified)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at StudentsManager.main(StudentsManager.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:267)
此外,目录名,顾名思义,是该文件应该创建目录的名称。在这种情况下,它是“学生”。
什么是'directoryName'?也可以使用堆栈跟踪粘贴整个异常 – Antoniossss
它不起作用,因为系统找不到指定的路径。 – Oleg
@Antoniossss编辑了问题 –