Decode a socket into lines with an explicit charset
Decode a socket into lines with an explicit charset
Answer
BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); String line = in.readLine();
InputStreamReader is the crossing from bytes to characters and the only place the charset is named; BufferedReader adds readLine(), which returns the line without its terminator and null at end of stream.
Harold 4e ch2 §Readers and Writers