title: String to byte array and vice versa after having sent data over sockets
body: <p>I've got a Client and a Server, both running on the same Computer (with Windows 7 OS). Programming language is java.</p>
  
  <p>to send a message I use:</p>
  
  <pre><code>public static void sendMessage(Socket socket,String message) throws IOException{
      byte[] mBytes = message.getBytes();
      output.write(mBytes, 0, mBytes.length);
      output.flush();
  }
  </code></pre>
  
  <p>and to receive I use:</p>
  
  <pre><code> byte read = (byte) input.read();
  </code></pre>
  
  <p>several times (the method is quite long, but the details I think arent that important) and store the result in a <code>byte[] messageBytes</code>. To retain the message I use</p>
  
  <pre><code>String message = new String(messageBytes);
  </code></pre>
  
  <p>This worked for me quite well. But I am wondering about the encodings used here. Will it be ok to use <code>getBytes()</code> on the one host and <code>new String(byte[] bytes)</code> on the other host? Is it good style to act like that?</p>