Server:
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
String s = inFromClient.readLine();
System.out.println("> "+s);
This simple code is returning the following output:
Howtomakeitnotshowthesesquareintheoutput,butrathershowthecontentthemessage(fifthlineoftheconsole)?
Completecode:
packagecom.estilosoft.servidor;importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.net.ServerSocket;importjava.net.Socket;publicclassServidor{publicstaticvoidmain(String[]args)throwsIOException{//TODOAuto-generatedmethodstubStringclientSentence;Stringcapitalized;ServerSocketsocket=null;try{//CriaumSocketServer(Socketcaracterísticodeumservidor)socket=newServerSocket(6831);System.out.println("abriu");
while(true) {
Socket connectionSocket = socket.accept();
System.out.println("Con "+ connectionSocket.getInetAddress().getHostAddress());
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
System.out.println("Iniciou");
String s = inFromClient.readLine();
System.out.println("Acabou");
System.out.println("> "+s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
socket.close();
System.out.println("fechou");
}
}
}