Netbeans FileReader FileNotFound文件在文件夹中的异常? [英] Netbeans FileReader FileNotFound Exception when the file is in folder?
问题描述
所以问题是我每次尝试在NetBeans或Eclips上加载代码时都会发生异常,但是当我尝试通过TextMate运行代码时,一切正常!
我试图把绝对地址,改变文本文件等..没有帮助!有人可以帮我或告诉为什么不能用IDE运行?
谢谢
void loadFile(){
try {
list = new LinkedList< Patient>();
FileReader read = new FileReader(a.txt);
扫描仪扫描=新扫描仪(读);
while(scan.hasNextLine()){
String Line = scan.nextLine();
String [] subArray = new String [5];
subArray = Line.split(,);
int a = Integer.parseInt(subArray [4]);
list.add(new Patient(Integer.parseInt(subArray [0])),subArray [1],subArray [2],subArray [3],a));
}
} catch(FileNotFoundException e){
JOptionPane.showMessageDialog(null,该文件不存在!+\\\
Program正在终止,找不到文件 JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
cap = list.size();
search_names = new int [cap]; (int i = 0; i< list.size(); i ++){
search_names [i] = i;
}
setNames(search_names);
} // end loadFile
调试日志:
没有/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar
的文件没有/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport的文件。框架/资源/ Java / JavaRuntimeSupport.jar
没有/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar
的文件没有/ System / Library / Java / JavaVirtualMachines / 1.6.0.jdk / Contents / Classes / sunrsasign.jar
}
在netbeans中,默认工作目录始终是根文件夹,我的意思是包含名称为src,build等的文件夹的文件夹。将文件与这些文件夹一起放置,它将做的诀窍。
so the problem is that I am having exception thrown each time I try to load the code below on NetBeans or Eclips, but when I try to run it thru TextMate everything works fine!
I tried to put the absolute address, changed the text file etc.. didn't help!
Can someone help me or tell why it won't run with IDE?
Thanks
void loadFile() {
try {
list = new LinkedList<Patient>();
FileReader read = new FileReader("a.txt");
Scanner scan = new Scanner(read);
while (scan.hasNextLine()) {
String Line = scan.nextLine();
String[] subArray = new String[5];
subArray = Line.split(",");
int a = Integer.parseInt(subArray[4]);
list.add(new Patient(Integer.parseInt(subArray[0]), subArray[1], subArray[2], subArray[3], a));
}
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "The file does not exist!" + "\nProgram is terminating.", "File Not Found", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
cap = list.size();
search_names = new int[cap];
for (int i = 0; i < list.size(); i++) {
search_names[i] = i;
}
setNames(search_names);
}//end loadFile
Debug log:
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar
Have no file for /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar
}
In netbeans the default working directory is always the root folder, i mean the folder which contains the folders which name "src", "build" etc. Place the file along with these folders and it will do the trick.
这篇关于Netbeans FileReader FileNotFound文件在文件夹中的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!