FileDocCategorySizeDatePackage
ResponseUtil.javaAPI DocGlassfish v2 API3837Fri May 04 22:32:30 BST 2007org.apache.catalina.util

ResponseUtil

public final class ResponseUtil extends Object

Fields Summary
Constructors Summary
Methods Summary
public static java.io.IOExceptioncopy(java.io.InputStream istream, javax.servlet.ServletOutputStream ostream)
Copies the contents of the specified input stream to the specified output stream.

param
istream The input stream to read from
param
ostream The output stream to write to
return
Exception that occurred during processing, or null


        IOException exception = null;
        byte buffer[] = new byte[2048];
        int len = buffer.length;
        while (true) {
            try {
                len = istream.read(buffer);
                if (len == -1)
                    break;
                ostream.write(buffer, 0, len);
            } catch (IOException e) {
                exception = e;
                len = -1;
                break;
            }
        }
        return exception;

    
public static java.io.IOExceptioncopy(java.io.Reader reader, java.io.PrintWriter writer)
Copies the contents of the specified input stream to the specified output stream.

param
reader The reader to read from
param
writer The writer to write to
return
Exception that occurred during processing, or null


        IOException exception = null;
        char buffer[] = new char[2048];
        int len = buffer.length;
        while (true) {
            try {
                len = reader.read(buffer);
                if (len == -1)
                    break;
                writer.write(buffer, 0, len);
            } catch (IOException e) {
                exception = e;
                len = -1;
                break;
            }
        }
        return exception;