Beispiel #1
0
  public char getchr() throws IOException
  {
    if((peek < 0) && (last_char != ' ') && (last_char != '\t'))
    {
      if((last_char != '\n') && (last_char != '\r'))
        p_char = last_char;
    }
    if(peek > 0)        /* char was read previously */
    {
      last_char = peekc;
      peek = -1;
    }
    else                    /* read next char in string */
    {
      indexBlock++;
      if (indexBlock >= lineLength)
      {
        for (int ib=0; ib<readCount; ib++) chars[ib] = '\0';

        lineLength = readCount = 0;
        reader.mark(1);
        if (reader.read() != -1)
        {
          reader.reset();  // back to the mark
          readCount = reader.read(chars);
          lineLength = readCount;
          strBlock = new String(chars);
          indexBlock = 0;
          last_char = strBlock.charAt(indexBlock);
          peek = -1;
          peekc = '`';
        }
        else
        {
          EOF = 1;
          peekc  = '\0';
        }
      }
      else
      {
        last_char = strBlock.charAt(indexBlock);
      }
    }
    peek = -1;
    if (last_char == '\r')
    {
      last_char = getchr();
    }

    return last_char;
  }