String str1 = null;
BufferedReader Read1 = new BufferedReader(new InputStreamReader(
System.in));
try {
str1 = Read1.readLine();
} catch (IOException e1) {
// TODO Auto-generated catch block
System.out.println("error!!!");
e1.printStackTrace();
}
PrintWriter fd = null;
try {
fd = new PrintWriter(new FileWriter("out.txt"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (str1 != null) { //就是这个判定出问题
fd.println(str1);
try {
str1 = Read1.readLine();
} catch (IOException e) {
e.printStackTrace();
}
fd.flush();
}
System.out.println("Founction1 terminated!!"); fd.close();
System.out.println();
System.out.println();上面的程序断点调试的时候 在需要输入的时候直接回车str1的值已经是""了 但是while循环依然继续执行而不会结束 为什么??
BufferedReader Read1 = new BufferedReader(new InputStreamReader(
System.in));
try {
str1 = Read1.readLine();
} catch (IOException e1) {
// TODO Auto-generated catch block
System.out.println("error!!!");
e1.printStackTrace();
}
PrintWriter fd = null;
try {
fd = new PrintWriter(new FileWriter("out.txt"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (str1 != null) { //就是这个判定出问题
fd.println(str1);
try {
str1 = Read1.readLine();
} catch (IOException e) {
e.printStackTrace();
}
fd.flush();
}
System.out.println("Founction1 terminated!!"); fd.close();
System.out.println();
System.out.println();上面的程序断点调试的时候 在需要输入的时候直接回车str1的值已经是""了 但是while循环依然继续执行而不会结束 为什么??
解决方案 »
- SqlServer1433端口问题
- 请问Infinity到底是什么东西?.java
- 关于接口和继承的基础知识的一个疑问
- lomboz修改class后 重新generate ejb classes 出错 怎么回事
- Java 关于paintComponent与paint有什么区别?各自的特点?
- 各位大哥,介绍几本学java的书吧~~初学者
- 我的显示在jFrame中的图片,只要一动窗口就没有了?请问是怎么回事?如何解决?
- 怎样创建一个没有标题栏的对话框?
- lichlong(传龙),jant在哪下载?
- 一个想不通的问题,求助,在线等
- 用JAVA怎么更改目录名?用什么涵数,或用什么办法?
- struts里面怎么对<html:text>进行javascript编程?
改成
while(!str.equals(" "))
“” 对象已经存在了,只是它的值是空的。
while(!str1.equals(""))