[英]Java method println being skipped
// out.println(" ");//solution
for (Utilizador ut : Diretorio.getInstance().getUtilizadores()) {
String s = ("CLT " + ut.getEndereco() + " " + ut.getPorto() );
out.println(s);
}
out.println("END");
System.out.println("Consulta realizada");
So i send this to my out stream, but then in my "in" stream i only receive "END" (if the list only has 1 object) if the list has 2 objects my "in" stream will show only 1 object and then END Here is my "in" 所以我将其发送到我的输出流,但是在我的“输入”流中,我仅收到“ END”(如果列表只有1个对象),如果列表有2个对象,我的“输入”流将仅显示1个对象,然后结束这是我的“中”
} else if(in.readLine()!=null){
while((msg = in.readLine())!= null){
System.out.println(msg);
}
}
Cant understand why one of my "out.println()" is being skipped or simply not shown Both classes are Threads 无法理解为什么我的“ out.println()”之一被跳过或根本没有显示这两个类都是线程
in this code 在这段代码中
} else if(in.readLine()!=null){
while((msg = in.readLine())!= null){
System.out.println(msg);
}
}
when if(in.readLine()!=null)
is executed a line is read but not printed and then in the while
loop every msg = in.readLine()
reads another line and print it. 当执行
if(in.readLine()!=null)
读取一行但不打印,然后在while
循环中,每个msg = in.readLine()
读取另一行并打印。
But the 1st line is never printed. 但是第一行从不打印。
Change it to: 更改为:
} else {
while((msg = in.readLine())!= null){
System.out.println(msg);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.