【发布时间】:2014-07-17 02:32:26
【问题描述】:
在 android 中,我从 BufferedReader 获取 String 值,从文件读取后它为 null。
intstring = br.readLine();
System.out.println(intstring);
if(intstring != null)
{
System.out.println("Inside if condition");
int istring = Integer.parseInt(intstring);
}
我的输出是
null
Inside if condition
NumberFormatException
请帮帮我
【问题讨论】:
-
@ThusithaThilinaDayaratne:
.equals()不需要检查null。 -
真的是
null吗?还是只是“空”? -
使用 equals() 方法。在此处阅读更多信息:stackoverflow.com/questions/513832/…
-
检查您的文件或输入...我认为它给出了“null”作为输入...这是有效的字符串和字符串 != null 将适用于这种情况。
-
可能输出的字符为“null”,它是一个字符串。交叉检查一次。
标签: java string nullpointerexception bufferedreader numberformatexception