out.flush();
writer.flush();
    private void flushBuffer (StringBuffer buf)    {        int           currentLength = 0;        int           length        = buf.length();        int           lineLength    = getLineLength();        int           tokenLength;        char          contents[];        StringBuffer  currentWord   = new StringBuffer();        boolean       lastWasNewline= true;        int           lines = 0;        int           tokensOnLine  = 0;        if (prefix != null)        {            // Emit the prefix, unless the line is empty.            if ( (length > 1) || (buf.charAt(0) != NEWLINE_MARKER) )            {                // Non empty line. We want the prefix.                if (emittedPrefix)                {                    for (int i = 0; i < prefix.length(); i++)                        out.print (' ');                }                else                {                    out.print (prefix);                }                // We've emitted a prefix, which by definition is at the                // beginning of a line. Pretend we've emitted a newline.                currentLength += prefix.length();                lastWasNewline = false;                emittedPrefix = true;            }        }        contents = buf.toString().toCharArray();        for (int i = 0; i < length; i++)        {            char c = contents[i];            if ( (c == NEWLINE_MARKER) || (Character.isSpaceChar (c)))            {                // Words are delimited by white space, so if there's a                // current word, we have to emit it at this point, before                // handling the white space character.                                    if ( (tokenLength = currentWord.length()) > 0 )                {                    // We have a word buffered up. Emit it.                    if ( ((currentLength + tokenLength) > lineLength) &&                         (tokensOnLine > 0) )                    {                        // Token would overflow the line AND we're not at                        // the beginning of a new line. Wrap first. (If we                        // were at the beginning of a new line, forcing a                        // "wrap" would introduce a spurious newline.)                        out.println();                        lines++;                        lastWasNewline = true;                        currentLength = 0;                        tokensOnLine = 0;                    }                    if (lastWasNewline && (lines > 0))                        currentLength += indent();                    out.print (currentWord.toString());                    lastWasNewline = false;                    currentLength += tokenLength;                    currentWord.setLength (0);                    tokensOnLine++;                }                // Now emit the white space character, wrapping the line if                // necessary first.                if ((c == NEWLINE_MARKER) || (currentLength >= lineLength))                {                    out.println();                    lines++;                    currentLength = 0;                    tokensOnLine = 0;                    lastWasNewline = true;                }                if (c != NEWLINE_MARKER)                {                    if (lastWasNewline)                        currentLength += indent();                    else                    {                        out.print (c);                        currentLength++;                    }                    lastWasNewline = false;                }            }            else            {                // Not a white space character. Add it to the current word.                currentWord.append (c);            }        } // end for        if ( (tokenLength = currentWord.length()) > 0 )        {            // Leftover word. Put it out, too.            if ( (! lastWasNewline) &&                 ((currentLength + tokenLength) > lineLength) )            {                out.println();                lines++;                lastWasNewline = true;                tokensOnLine = 0;            }            if (lastWasNewline)                currentLength += indent();            out.print (currentWord.toString());            lastWasNewline = false;        }        // Issue a final newline and flush the output stream.        if (! lastWasNewline)            out.println();        out.flush();    }