public void write(String str, int off, int len) throws IOException
    {
        // Get just the portion of the input string to display
        String inputString = str.substring(off, off + len);

        StringBuffer outputString = new StringBuffer();

        // Build a string tokenizer that uses '\n' as its splitting character
        // Cycle through all tokens
        for (StringTokenizer tokenizer = new StringTokenizer(inputString, "\n", true); tokenizer.hasMoreTokens();)
        {
            // Replace '\n' token with a <br>
            String nextToken = tokenizer.nextToken();

            if ("\n".equals(nextToken))
            {
                outputString.append("<br>");
            }
            else
            {
                outputString.append(nextToken);
            }
        }

        // Write out the generated string
        out.write(outputString.toString());
    }
public void write(String str, int off, int len) throws IOException
    {
        
        String inputString = str.substring(off, off + len);

        StringBuffer outputString = new StringBuffer();

        
        
        for (StringTokenizer tokenizer = new StringTokenizer(inputString, "\n", true); tokenizer.hasMoreTokens();)
        {
            
            String nextToken = tokenizer.nextToken();

            if ("\n".equals(nextToken))
            {
                outputString.append("<br>");
            }
            else
            {
                outputString.append(nextToken);
            }
        }

        
        out.write(outputString.toString());
    }
public void write ( String str , int off , int len ) throws IOException { // Get just the portion of the input string to display String inputString = str . substring ( off , off + len ) ; StringBuffer outputString = new StringBuffer ( ) ; // Build a string tokenizer that uses '\n' as its splitting character // Cycle through all tokens for ( StringTokenizer tokenizer = new StringTokenizer ( inputString , "\n" , true ) ; tokenizer . hasMoreTokens ( ) ; ) { // Replace '\n' token with a <br> String nextToken = tokenizer . nextToken ( ) ; if ( "\n" . equals ( nextToken ) ) { outputString . append ( "<br>" ) ; } else { outputString . append ( nextToken ) ; } } // Write out the generated string out . write ( outputString . toString ( ) ) ; }
Writes a string of characters to the filtered writer. Any newline characters '\n' are replaced with an HTML break
tag "&lt;br&gt;".

@param  str The character array to write.
@param  off The offset into the array to begin writing from.
@param  len The number of characters to write.

@throws IOException If the writer won't accept the string.
Writes a string of characters to the filtered writer . Any newline characters \ n are replaced with an HTML break tag &lt ; br&gt ; .