About getline() method in Java

Recently, I was trying to use an example program in Java to communicate with another C++ program through net socket. The example use a method in Class Stream called getline() to read from the socket with cause a problem that I failed to receive anything which is already sent.

There are two reasons:

First, this method will stuck the thread until a line is read. This disable all the debug output in my program.

Second, the method will only return if a \n sign or /r sign is read which is not contained in what’s sent. This disable the method from outputting anything and also stuck it forever.

2017/2/20 12:33