title: Android outputStream.write send multiple messages
body: <p>is there a way to send multiple messages with <code>OutputStream.write(bytes[])</code>, for example when i call twice my function to write <code>func.write("hi"); func.write(" how are you");</code>, I receive the message "concateneted" like this: <code>"hi how are you"</code>, but i want two different messages, is there a way to do it without using separators in my message, i mean know when the other device receives the message, here is my code (its the android bluetooth sample):</p>
  
  <pre><code>private class ConnectedThread extends Thread {
      private final BluetoothSocket mmSocket;
      private final InputStream mmInStream;
      private final OutputStream mmOutStream;
  
      public ConnectedThread(BluetoothSocket socket, String socketType) {
          Log.d(TAG, "create ConnectedThread: " + socketType);
          mmSocket = socket;
          InputStream tmpIn = null;
          OutputStream tmpOut = null;
  
          // Get the BluetoothSocket input and output streams
          try {
              tmpIn = socket.getInputStream();
              tmpOut = socket.getOutputStream();
          } catch (IOException e) {
              Log.e(TAG, "temp sockets not created", e);
          }
  
          mmInStream = tmpIn;
          mmOutStream = tmpOut;
      }
  
      public void run() {
          Log.i(TAG, "BEGIN mConnectedThread");
          byte[] buffer = new byte[1024];
          int bytes;
  
          // Keep listening to the InputStream while connected
          while (true) {
              try {
                  // Read from the InputStream
                  bytes = mmInStream.read(buffer);
  
                  // Send the obtained bytes to the UI Activity
                  mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, buffer)
                          .sendToTarget();
              } catch (IOException e) {
                  Log.e(TAG, "disconnected", e);
                  connectionLost();
                  // Start the service over to restart listening mode
                  BluetoothChatService.this.start();
                  break;
              }
          }
      }
  
      /**
       * Write to the connected OutStream.
       * @param buffer  The bytes to write
       */
      public void write(byte[] buffer) {
          try {
              mmOutStream.write(buffer);
  
              // Share the sent message back to the UI Activity
              mHandler.obtainMessage(BluetoothChat.MESSAGE_WRITE, -1, -1, buffer)
                      .sendToTarget();
          } catch (IOException e) {
              Log.e(TAG, "Exception during write", e);
          }
      }
  
      public void cancel() {
          try {
              mmSocket.close();
          } catch (IOException e) {
              Log.e(TAG, "close() of connect socket failed", e);
          }
      }
  }
  </code></pre>