Class ByteArrayPrintWriter


  • public class ByteArrayPrintWriter
    extends Object
    PrintWriter which uses an underlying ByteArrayOutputStream
    Author:
    Mike Douglass douglm @ rpi.edu
    • Constructor Detail

      • ByteArrayPrintWriter

        public ByteArrayPrintWriter()
    • Method Detail

      • getWriter

        public PrintWriter getWriter()
        Returns:
        PrintWriter for this object
      • getStream

        public javax.servlet.ServletOutputStream getStream()
        Returns:
        a ServletOutputStream
      • getInputStream

        public InputStream getInputStream()
                                   throws IOException
        Get an InputStream for the bytes in the buffer. No guarantees if writes take place after this is called.
        Returns:
        InputStream
        Throws:
        IOException
      • writeTo

        public void writeTo​(OutputStream out)
                     throws IOException
        Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).
        Parameters:
        out - the output stream to which to write the data.
        Throws:
        IOException - if an I/O error occurs.
      • size

        public int size()
        Returns the current size of the buffer.
        Returns:
        the value of the count field, which is the number of valid bytes in this output stream.
        See Also:
        ByteArrayOutputStream.count