Class OutputStreamHandler

  • All Implemented Interfaces:
    Flushable, AutoCloseable
    Direct Known Subclasses:
    ConsoleHandler, FileHandler

    public class OutputStreamHandler
    extends WriterHandler
    An output stream handler which supports any OutputStream, using the specified encoding. If no encoding is specified, the platform default is used.
    • Constructor Detail

      • OutputStreamHandler

        public OutputStreamHandler()
        Construct a new instance with no formatter.
      • OutputStreamHandler

        public OutputStreamHandler​(Formatter formatter)
        Construct a new instance.
        Parameters:
        formatter - the formatter to use
      • OutputStreamHandler

        public OutputStreamHandler​(OutputStream outputStream,
                                   Formatter formatter)
        Construct a new instance.
        Parameters:
        outputStream - the output stream to use
        formatter - the formatter to use
    • Method Detail

      • setCharsetPrivate

        protected void setCharsetPrivate​(Charset charset)
                                  throws SecurityException
        Description copied from class: ExtHandler
        Set the handler's character set from within this handler. If not set, the handler's character set is initialized to the platform default character set.
        Overrides:
        setCharsetPrivate in class ExtHandler
        Parameters:
        charset - the character set (must not be null)
        Throws:
        SecurityException
      • getCharset

        public Charset getCharset()
        Description copied from class: ExtHandler
        Get the handler's character set.
        Overrides:
        getCharset in class ExtHandler
        Returns:
        the character set in use (not null)
      • setWriter

        public void setWriter​(Writer writer)
        Set the writer. The writer will then belong to this handler; when the handler is closed or a new writer is set, this writer will be closed. Setting a writer will replace any target output stream.
        Overrides:
        setWriter in class WriterHandler
        Parameters:
        writer - the new writer, or null to disable logging
      • setOutputStream

        public void setOutputStream​(OutputStream outputStream)
        Set the output stream to write to. The output stream will then belong to this handler; when the handler is closed or a new writer or output stream is set, this output stream will be closed.
        Parameters:
        outputStream - the new output stream or null for none