title: Java Socket.readLine() not always reading whole message separated by newLine
body: <p>readLine() works fine in many cases but few times, the line I read in by BufferedReader.readLine() is incomplete line. <a href="https://stackoverflow.com/questions/9436609/bufferedreader-readline-before-the-line-is-complete">This</a> question talks about similar issue. However the solutions are not satisfactory. A solution there says that it maybe because of EOF character. But in my case I am not sending any EOF character at all. Below are my codes:</p>
  
  <pre><code>/*Sending Code*/
  public void sendToLocalDaemon(String msg){/*msg have no New line or \r*/
          localMachineWriter.println(msg);
  }
  /*Receiving Code*/
  public int receiveFromCoordinator(){
          String response = "";
          while(true){/*Each message separated from new line will have its independent meaning.*/
              try{
                      coordinator.setSoTimeout(1);
                      try{
                          response = coordinatorReader.readLine();
                      }
                      catch(java.net.SocketTimeoutException e){
                          response = null;
                      }
                      if(response == null){
                          return coordinatorsMessage.size();
                      }
                      coordinatorsMessage.add(response);
              }
              catch(IOException e){
                  log(e.getMessage());
                  //System.exit(0);
              }
      }
  }
  /*This is how I set reader and writer*/
  
  public void setReaderWriter() throws IOException{
      this.coordinatorWriter = new PrintWriter(coordinator.getOutputStream(),true);
      this.coordinatorReader = new BufferedReader(new InputStreamReader(coordinator.getInputStream()));
  }
  </code></pre>
  
  <p>Please either suggest me someway to make this work correctly. Or suggest me some other way by which I can read whole message, with 100% guarantee.</p>