コード例 #1
0
  /**
   * Returns the next character in the filtered stream. If the desired number of lines have already
   * been read, the resulting stream is effectively at an end. Otherwise, the next character from
   * the underlying stream is read and returned.
   *
   * @return the next character in the resulting stream, or -1 if the end of the resulting stream
   *     has been reached
   * @throws IOException if the underlying stream throws an IOException during reading
   */
  public final int read() throws IOException {
    if (!getInitialized()) {
      initialize();
      setInitialized(true);
    }

    while (line == null || line.length() == 0) {
      line = lineTokenizer.getToken(in);
      if (line == null) {
        return -1;
      }
      line = stripSection(line);
      linePos = 0;
    }

    int ch = line.charAt(linePos);
    linePos++;
    if (linePos == line.length()) {
      line = null;
    }
    return ch;
  }
コード例 #2
0
 /**
  * Creates a new filtered reader.
  *
  * @param in A Reader object providing the underlying stream. Must not be <code>null</code>.
  */
 public StripSection(final Reader in) {
   super(in);
   lineTokenizer = new LineTokenizer();
   lineTokenizer.setIncludeDelims(true);
 }