0
我有它有3个字的文本文件,并试图读到这些话,我得到以下错误:java.util.NoSuchElementException阅读文件(扫描仪)
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at search.search(search.java:121)
at main.main(main.java:38)
下面是代码问题:
Scanner reader = new Scanner(path + client + "\\" + cat +"\\" + query + ".arch");
while (reader.hasNext()){
String a = reader.next(); // line 121
String b = reader.next();
String c = reader.next();
file = new File (path + client + "\\" + a +"\\" + b + ".arch");
print(file);
}
下面是该文件的内容:
po ref refc (with a new line at the end)
是怎么回事? 我以前使用过一个非常类似的系统,使用相同的文件,并且一切正常,我甚至在下面使用了一个非常类似的系统。
顺便说一下,字符串c尚未实现,但应进一步向下。
感谢您的回复;我试图通过将扫描仪更改为Scanner reader = new Scanner(新文件(路径+客户端+“\\”+ cat +“\\”+ querry +“.arch”))来修复它。 – NoobLevler 2012-07-22 17:45:00