code: public Object read() throws IOException {
      char[] buffer = new char[BUFFER_LENGTH];
      reader.mark(BUFFER_LENGTH);
      int count = 0;
      int textEnd;
  
      while (true) {
        int r = reader.read(buffer, count, buffer.length - count);
  
        if (r == -1) {
          // the input is exhausted; return the remaining characters
          textEnd = count;
          break;
        }
  
        count += r;
        int possibleMarker = findPossibleMarker(buffer, count);
  
        if (possibleMarker != 0) {
          // return the characters that precede the marker
          textEnd = possibleMarker;
          break;
        }
  
        if (count < marker.length()) {
          // the buffer contains only the prefix of a marker so we must read more
          continue;
        }
  
        // we've read a marker so return the value that follows
        reader.reset();
        String json = reader.readLine().substring(marker.length());
        return jsonParser.parse(json);
      }
  
      if (count == 0) {
        return null;
      }
  
      // return characters
      reader.reset();
      count = reader.read(buffer, 0, textEnd);
      return new String(buffer, 0, count);
    }
docs: Returns the next value in the stream: either a String, a JsonElement, or
  null to indicate the end of the stream. Callers should use instanceof to
  inspect the return type.