private final void FillBuff () throws java.io.IOException
    {
        // Buffer fill logic:
        // If there is at least 2K left in this buffer, just read some more
        // Otherwise, if we're processing a token and it either
        // (a) starts in the other buffer (meaning it's filled both part of
        //     the other buffer and some of this one, or
        // (b) starts in the first 2K of this buffer (meaning its taken up
        //     most of this buffer
        // we expand this buffer.  Otherwise, we swap buffers.
        // This guarantees we will be able to back up at least 2K characters.
        if (curBuf.size - curBuf.dataLen < 2048)
        {
            if (tokenBeginPos >= 0
                    && ((tokenBeginBuf == curBuf && tokenBeginPos < 2048)
                    || tokenBeginBuf != curBuf))
            {
                curBuf.expand(2048);
            }
            else
            {
                swapBuf();
                curBuf.curPos = curBuf.dataLen = 0;
            }
        }

        try
        {
            int i = inputStream.read(curBuf.buffer, curBuf.dataLen,
                    curBuf.size - curBuf.dataLen);
            if (i == -1)
            {
                inputStream.close();
                inputStreamClosed = true;
                throw new java.io.IOException();
            }
            else
                curBuf.dataLen += i;
            return;
        }
        catch (java.io.IOException e)
        {
            if (curBuf.curPos > 0)
                --curBuf.curPos;
            if (tokenBeginPos == -1)
            {
                tokenBeginPos = curBuf.curPos;
                tokenBeginBuf = curBuf;
            }
            /*
            if (e instanceof sun.io.MalformedInputException)
            {
                // it's an ugly hack, but we want to pass this exception
                // through the JavaCC parser, since it has a bad
                // exception handling
                throw new RuntimeException("MalformedInput", e);
            }
            */
            throw e;
        }
    }