我被要求写一个文件阅读器的方法,我做了一个工作正常,但无法取得第二个一个工作,保持我打开booms.txt文件后,收到此错误问题的缓冲文件读取
Error:java.util.NoSuchElementException
公共实例变量,我使用的文件阅读器
try
{ int x; int y; double boomTime; boolean isAHit; Scanner lineScanner; bufferedFileReader = new BufferedReader(new FileReader(aFile)); String currentLine = bufferedFileReader.readLine(); while (currentLine != null) { lineScanner = new Scanner(currentLine); lineScanner.useDelimiter(","); x = lineScanner.nextInt(); y = lineScanner.nextInt(); boomTime = lineScanner.nextDouble(); isAHit = lineScanner.nextBoolean(); booms.add(new Boom(x,y,boomTime)); currentLine = bufferedFileReader.readLine(); } } catch (Exception anException) { System.out.println("Error:"+anException); } finally { try { bufferedFileReader.close(); } catch (Exception anException) { System.out.println("Error:" +anException); } } }
public List booms;
代码请帮忙
为什么不查询详情堆栈跟踪? _anException.printStackTrace(); _ – 2010-09-15 19:31:49
你知道哪个例外的错误是从哪里打印的?尝试改变你的输出是不同的 - 例如,使一个“读取错误:”和一个“关闭错误:”。然后,就像Nikita建议的那样,尝试打印堆栈跟踪以查看抛出异常的位置。 – aperkins 2010-09-15 19:33:59
它来自错误1 – user448792 2010-09-15 19:38:24