我正在尝试读取.tab文件,但是收到NullPointerException错误。
Exception in thread "main" java.lang.NullPointerException
at project.FTAFileReader.<init>(FTAFileReader.java:37)
at project.FTAFileReader.main(FTAFileReader.java:103)
请找到以下代码
public FTAFileReader(){
try {
BufferedReader buffer;
buffer = new BufferedReader(new FileReader("event_trace.tab"));
buffer.readLine(); //Skips the first line of the file.
String currentstr;
while((currentstr=buffer.readLine().trim()) != null){
String[] column = currentstr.split("\\s+");
if(column.length>0){
//hostID.add(Long.parseLong(column[0]));
eventID.add(Integer.parseInt(column[0]));
componentID.add(Integer.parseInt(column[1]));
nodeID.add(Integer.parseInt(column[2]));
platformID.add(Integer.parseInt(column[3]));
nodeName.add(Double.parseDouble(column[4]));
eventType.add(Integer.parseInt(column[5]));
eventStartTime.add(Long.parseLong(column[6]));
eventStopTime.add(Long.parseLong(column[7]));
eventEndReason.add(Integer.parseInt(column[8]));
}
}
}
catch (IOException e) {
e.printStackTrace();
System.out.println("The simulation has been terminated due to an IO error");
}
}
任何帮助都会非常值得注意。提前谢谢。
Yogesh Sharma