title: Checking and breaking out of a do-while loop
body: <p>I am sending serial data to my android device from an external Bluetooth device as follows:</p>
  
  <p>Send '*' ----> Send data----> Send '#'</p>
  
  <p>Can somebody tell me why this code is not working? It is not displaying anything.</p>
  
  <p>At the receiver end the code is as follows:
  BluetoothChat.java</p>
  
  <pre><code>public String myteststring;
  private static boolean check=true;
  
  // The Handler that gets information back from the BluetoothChatService
  private final Handler mHandler = new Handler() {
      @Override
      public void handleMessage(Message msg) {
  
          switch (msg.what) {
  
              case MESSAGE_READ:
  
                  byte[] readBuf = (byte[]) msg.obj;
  
                  // construct a string from the valid bytes in the buffer
                  String readMessage = new String(readBuf, 0, msg.arg1);
  
                  if(!readMessage.matches("\\*")) {
                      mConversationArrayAdapter.add("Error!");
                      check=false;
                  }
  
                  do {
                      if(readMessage.matches("\\*")) {
                          mConversationArrayAdapter.add("Start");
                          myteststring = " ";
  
                      } else if(readMessage.matches("\\#")) {
                          mConversationArrayAdapter.add(myteststring);
                          mConversationArrayAdapter.add("End");
                          break;
                      } else  {
                          //mConversationArrayAdapter.add(readMessage);
                          myteststring=myteststring.concat(readMessage);
                      }
  
                  } while(check);
  
               case MESSAGE_WRITE:
                      //code
                      break;
          }
      }
  }
  </code></pre>