code: public static boolean streamHasText(InputStream in, String text) {
      final byte[] readBuffer = new byte[8192];
  
      StringBuffer sb = new StringBuffer();
      try {
        if (in.available() > 0) {
          int bytesRead = 0;
          while ((bytesRead = in.read(readBuffer)) != -1) {
            sb.append(new String(readBuffer, 0, bytesRead));
  
            if (sb.toString().contains(text)) {
              sb = null;
              return true;
            }
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          in.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
  
      return false;
    }
docs: Checks if the InputStream have the text
  
  @param in InputStream to read
  @param text Text to check
  @return whether the inputstream has the text