android - java - Socket Stream -
I have to get the text from the stream but I do not get it correctly.
Everything works well, but I only need to know how PrintWriter can be obtained in the string.
I tried to convert printWriter with the function. Toaster () but it does not work correctly, the print is an alter string.
Java:
Private serverSockets server signals; Personal Static FINAL END CLIENTRPORT = 5000; Socket socket = faucet; Class Connect_To_Client tool runnable {@Override Public Zero Run () {try {Server_Socket = new ServerSocket (CLIENTRPORT); Socket = Server_Socket.accept (); } Hold (IOException e) {e.printStackTrace (); }}} Public BufferedReader input; Public string Get_Message_From_Server () {PrintWriter out = zero; String out_string = ""; Try {input = new BufferedReader (new InputStreamReader (socket.getInputStream ())); Println (input); } Hold (IOException e) {e.printStackTrace (); } Return (out_string); // text - problem}
read one from the Buffered Reader do something like this
BufferedReader Reader = new BufferedReader (new InputStreamReader (socket.getInputStream ())); Stringbilder sb = new stringbiller (); String line = reader Readline (); While (line! = Null) {sb.append (line); Line = reader. Readline (); } Return sb.toString ();
Comments
Post a Comment