title: Android : read from a buffer until a specific char or string is recieved
body: <p>I am new to this site as well as android. I trying to code for a TCP client. I can send data and receive as well. I want to read from the in buffer, I can use <code>in.readLine();</code> but this will just read until a new line. I will read until I receive <code>!!</code> or the Buffer is empty or the data in the received response is more than 160 chars.</p>
  
  <p>MY current code is</p>
  
  <pre><code>bSend.setOnClickListener(new Button.OnClickListener() {
          public void onClick(View v) {
              try {
                  String outMsg = textField.getText().toString().trim();
                  out.write(outMsg);
                  out.flush();
                  StringBuilder total = new StringBuilder();
                  BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
                  mstr=in.readLine();
                  tv.setText(mstr);
                  Log.i("TcpClient", "sent: " + mstr);
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
  
              finally{
  
              }
          }
  
  
      });
  </code></pre>