title: How to get data from TCP socket into a ByteBuffer
body: <p>I need to get incoming data from a socket into a ByteBuffer and I do not know how to do it. I am new to this field and therefore not sure of the best way to start. I found the following but that is not what I want as it gets the data in line but I need to have all of my data in bytebuffer for other purposes.</p>
  
  <pre><code>ServerSocket welcomeSocket = new ServerSocket(Integer.parseInt(ibmPort));
  while (true) {
      Socket connectionSocket = welcomeSocket.accept();                   
      BufferedReader inFromClient =  new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
      DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
      clientSentence = inFromClient.readLine();
      System.out.println("Received: " + clientSentence);
      setRequestDataFromCT(clientSentence);
      capitalizedSentence = clientSentence.toUpperCase() + '\n';
      outToClient.writeBytes(capitalizedSentence);
  }
  </code></pre>