Reputation: 107
// 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"
} 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
Upvotes: 0
Views: 81
Reputation: 164089
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.
But the 1st line is never printed.
Change it to:
} else {
while((msg = in.readLine())!= null){
System.out.println(msg);
}
}
Upvotes: 3