title: TCP Server-Client large json
body: <p>I currently have a TCP server (java desktop application) and client (android application) connected.</p>
  
  <p>I can send json string from client to server and from server to client, my issue is sometimes i need to send from the server a large string which gets cut.</p>
  
  <p>This is my code:</p>
  
  <p>SERVER SIDE </p>
  
  <pre><code>public void sendResponse(String response){
    PrintWriter writer = new PrintWriter(BufferedWriter(
                         new OutputStreamWriter(mClientSocket.getOutputStream())), true);
  
    if(writer != null &amp;&amp; !writer.checkError()){
       writer.println(response);
       writer.flush();
    }
  }
  </code></pre>
  
  <p>CLIENT SIDE</p>
  
  <pre><code>BufferedReader input = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
  String response;
  while((response = input.readLine()) != null &amp;&amp; mRun){
      Data data = new Gson().fromJson(response, Data.class);
      //when i try to convert the response to Data object using Gson
      //it gives me a com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 106498
  
  }
  </code></pre>
  
  <p>as you can see the error on client side happens because the string was to large so it got cut off, 
  can someone please tell me what to do in this case?</p>
  
  <p>thanks in advance.</p>