当我运行程序时显示
错误:对于输入字符串:“NA”
喜欢这张图片:http://upic.me/i/nr/55untitled.png
这是我的错误部分代码
public static void convertFile(){
try {
myDataRecordList = new ArrayList<Flight>();
FileInputStream fstream = new FileInputStream("res\\2008.csv");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
br.readLine(); //Skip First Line
while ((strLine = br.readLine()) != null) {
String[] myString = strLine.split(",");
Flight myNewRecord = new Flight(myString);
myDataRecordList.add(myNewRecord);
}
in.close();
writeFile();
} catch (Exception e) {
System.err.println("Error : " + e.getMessage());
}
}
感谢。
答案 0 :(得分:0)
你可以把完整的Stacktrace放在下面这样:
java.lang.NumberFormatException: For input string: "N/A"
at java.lang.NumberFormatException.forInputString(Unknown Source)
在你看看你正在创建Flight myNewRecord = new Flight(myString);
对象你在Flight
的构造函数中用字符串做什么。
在构造函数中传递的字符串是"N/A"
所以如果你没有处理这个案例,那么就是因为你得到了这个例外。
注意:除了打印错误消息之外,您还可以打印Stack Trace,这样您就可以了解Exception的来源。