/** * Construct a new instance. * * @param outputStream the output stream to use * @param formatter the formatter to use */ public OutputStreamHandler(final OutputStream outputStream, final Formatter formatter) { setFormatter(formatter); setOutputStream(outputStream); }
if (outputStream == null) { this.setWriter(null); return; checkAccess(this); final OutputStream oldStream = this.outputStream; final Writer writer = getNewWriter(outputStream); try { this.outputStream = outputStream; super.setWriter(writer); } finally { safeFlush(oldStream); safeClose(oldStream); reportError("Error opening output stream", e, ErrorManager.OPEN_FAILURE); return;
/** * Construct a new instance. * * @param formatter the formatter to use */ public OutputStreamHandler(final Formatter formatter) { setFormatter(formatter); }
/** {@inheritDoc} */ public void setOutputStream(final OutputStream outputStream) { super.setOutputStream(wrap(outputStream)); } }
/** * Set the target encoding. * * @param encoding the new encoding * @throws SecurityException if you do not have sufficient permission to invoke this operation * @throws java.io.UnsupportedEncodingException if the specified encoding is not supported */ public void setEncoding(final String encoding) throws SecurityException, UnsupportedEncodingException { // superclass checks access synchronized (outputLock) { charset = encoding == null ? null : Charset.forName(encoding); super.setEncoding(encoding); // we only want to change the writer, not the output stream final OutputStream outputStream = this.outputStream; if (outputStream != null) { super.setWriter(getNewWriter(outputStream)); } } }
/** * Construct a new instance with no formatter. */ public OutputStreamHandler() { setFormatter(Formatters.nullFormatter()); }