Can not retrieve data from the socket
<p>I am a beginner in developing the java applications. I'm making a chat application on android. I use a thread to serve the client who comes in, but when the client has connected to the server I can not retrieve the data contained in the socket, but when a client connection is lost, data can be displayed. I use the ReadLine method to read data from the socket.
This is the program code on the server side:  </p>

<pre><code>package server;
import java.net.*;
import java.io.*;
import java.util.Vector;  

import com.sun.org.apache.bcel.internal.generic.NEW;  

public class Server {       

public static void main(String[] args)throws IOException, InstantiationException,
IllegalAccessException {            

    ServerSocket servsocket = null;  
    Socket sock = null;  
    byte[] bytebuffer = new byte[512];  

    try {
        System.out.println("SERVER IS RUNNING...");
        servsocket = new ServerSocket(28000);
        while(true){
        sock = servsocket.accept();
        System.out.println(servsocket.isBound());
        System.out.println("Port "+servsocket+" Ready!!!");
        System.out.println("Accept connection requests from " + sock);
        System.out.println("From CLIENT "+sock.getInetAddress()+ " and PORT " +  
            sock.getPort());
        ChatThread thread = new ChatThread(sock);  
        System.out.println("Thread is running");
        thread.run();       


        }
    } catch (IOException ioe) {
        System.out.println(ioe);
    } 
    finally{
            try {
                servsocket.close();
                } catch (IOException ioe) {
                    System.out.println(ioe);
                }
            }       
    }
    } 

class ChatThread extends Thread{
    static Vector&lt;ChatThread&gt; chatthread = new Vector&lt;ChatThread&gt;(10);
    private Socket sock;
    private BufferedReader in ;
    private PrintWriter out;

    public ChatThread (Socket socket) throws IOException {
        this.sock = socket;
        in = new BufferedReader(
                new InputStreamReader(socket.getInputStream()));
        out = new PrintWriter(
                new OutputStreamWriter(socket.getOutputStream()));

        byte[] bytebuffer = new byte[512];
        int receivemssg;

    }

    public void run(){
        int recvMsgSize;
        byte[] bytebuffer = new byte[512];
        String readsocket;
        try {
            readsocket = in.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
            }
                }   
</code></pre>

<p>Below the display on the server side when the program starts. I tried to send the word "Hello ...." from the client side. Can be seen that the thread is not running. </p>

<p>Server is running...
true
Port ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=28000] Ready!!!
 Accept connection requests fromSocket[addr=/172.17.231.254,port=3567,localport=28000]
From CLIENT /172.17.231.254 and PORT 3567
Thread is Running...      </p>

<p>When I replace the readline method on a thread with getInputStream the thread can be run from the client and the message can be displayed. This is the code that I enter the thread to replace the readline method that I used before. </p>

<pre><code>public ChatThread (Socket socket) throws IOException {
        this.sock = socket;
        in  = sock.getInputStream();
        out = sock.getOutputStream();
        byte[] bytebuffer = new byte[512];
        int receivemssg;

    }

    public void run(){
        int recvMsgSize;
        byte[] bytebuffer = new byte[512];

        System.out.println("Thread is Running...");
        String masuk = new String(bytebuffer);

        System.out.println(bytebuffer);
        System.out.println(in.toString());
        System.out.println("thread successfully executed !!!");

        synchronized (chatthread) {
            chatthread.addElement(this);
        }

         try {
            while ((recvMsgSize = in.read(bytebuffer)) != -1) {
                    out.write(bytebuffer, 0, recvMsgSize);
                    System.out.println("The length of a character is received and returned "+bytebuffer.length);
                 }
        } catch (IOException e) {

            System.out.println(e);
        }
                    }
                    }
</code></pre>

<p>but the next problem is I can not bring up the contents of a socket in a string / text that appears is as follows:</p>

<p>Port ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=28000] Siap!!!
 Accept connection requests fromSocket[addr=/172.17.231.254,port=3577,localport=28000]
From CLIENT /172.17.231.254 and PORT 3577
Thread is Running...
[B@7c6768
java.net.SocketInputStream@1690726
thread successfully executed !!!
The length of a character is received and returned 512      </p>

<p>Please Help me, thanks :) GBU guys...</p>
