BufferedReader readLine method hangs and block program

前端 未结 3 1225
说谎
说谎 2020-12-18 13:03

I\'m trying to learn sockets using Java and I sucessfully sent data to a ServerSocket running in my own machine. When I try to read from this socket using readline (so I can

3条回答
  •  时光取名叫无心
    2020-12-18 13:54

    writeUTF() doesn't write a line. See the Javadoc. writeUTF() is for use with readUTF(). And Readers are for use with Writers. So change the DataOutputStream to a BufferedWriter and call write() and then newline().

提交回复
热议问题