下面的这段代码为什么可以避免NullPointerException呢?我试了,把while那句改为while(!(str=buf.readLine()).equals(null))就报异常了
Buffered buf=new BufferedReader(new FileReader("c:\\1.txt"));
String str;
str=buf.readLine();
while(str!=null){
System.out.println(str);
str=buf.readLine();
}
我没分了不能给
Buffered buf=new BufferedReader(new FileReader("c:\\1.txt"));
String str;
str=buf.readLine();
while(str!=null){
System.out.println(str);
str=buf.readLine();
}
我没分了不能给
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货