首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

字符串格式转换的有关问题

2012-02-14 
字符串格式转换的问题try {bb new BufferedReader(new InputStreamReader(new FileInputStream(new File

字符串格式转换的问题
try {
bb = new BufferedReader(new InputStreamReader(
new FileInputStream(new File("F:\\测试2.txt"))));
String string = null;
while((string = bb.readLine()) != null) {
int ll = Integer.valueOf(string);
System.out.println(ll);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}finally {
try {
bb.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

文件第一行存了1,第二行存了3,为什么抛出java.lang.NumberFormatException,没有其他的字符啊

[解决办法]
字母l和数字1可不同哦,我觉得只有文件里面存放的不是数字字符才有可能出这个异常。

热点排行