/** * Sets the character encoding used by this handler. A {@code null} value * indicates that the default encoding should be used. * * @param encoding * the character encoding to set. * @throws SecurityException * if a security manager determines that the caller does not * have the required permission. * @throws UnsupportedEncodingException * if the specified encoding is not supported by the runtime. */ public virtual void setEncoding(String encoding)// throws SecurityException, // UnsupportedEncodingException { // flush first before set new encoding { this.flush(); base.setEncoding(encoding); // renew writer only if the writer exists if (null != this.writer) { if (null == getEncoding()) { this.writer = new java.io.OutputStreamWriter(this.os); } else { try { this.writer = new java.io.OutputStreamWriter(this.os, getEncoding()); } catch (java.io.UnsupportedEncodingException e) { /* * Should not happen because it's checked in * super.initProperties(). */ throw new java.lang.AssertionError(e); } } } }
/// <summary> /// Write the properties to the output stream. /// </summary> /// <param name="stream">The output stream where the properties are written.</param> /// <param name="comments">Optional comments that are placed at the beginning of the output.</param> public void Write(java.io.Writer stream, String comments) { // Create a writer to output to an ISO-8859-1 encoding (code page 28592). //StreamWriter writer = new StreamWriter( stream, System.Text.Encoding.GetEncoding( 28592 ) ); java.io.BufferedWriter writer = new java.io.BufferedWriter(stream); if (comments != null) { comments = "# " + comments; } writer.write(comments); writer.newLine(); writer.write("# " + DateTime.Now.ToString()); writer.newLine(); writer.flush(); for (IEnumerator e = hashtable.Keys.GetEnumerator(); e.MoveNext();) { String key = e.Current.ToString(); String val = hashtable[key].ToString(); writer.write(escapeKey(key) + "=" + escapeValue(val)); writer.newLine(); writer.flush(); } }
/** * Constructs a {@code StreamHandler} object. The new stream handler * does not have an associated output stream. */ public StreamHandler() { initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$ null); this.os = null; this.writer = null; this.writerNotInitialized = true; }
/** * Constructs a {@code StreamHandler} object. The specified default values * will be used if the corresponding properties are not found in the log * manager's properties. */ internal StreamHandler(String defaultLevel, String defaultFilter, String defaultFormatter, String defaultEncoding) { initProperties(defaultLevel, defaultFilter, defaultFormatter, defaultEncoding); this.os = null; this.writer = null; this.writerNotInitialized = true; }
private static void closeQuietly(java.io.Writer outJ) { if (outJ == null) { return; } try { outJ.close(); } catch (java.io.IOException e) { } }
/** * Sets the output stream this handler writes to. If there's an existing * output stream, the tail string of the associated formatter will be * written to it. Then it will be flushed, closed and replaced with * {@code os}. * * @param os * the new output stream. * @throws SecurityException * if a security manager determines that the caller does not * have the required permission. * @throws NullPointerException * if {@code os} is {@code null}. */ protected void setOutputStream(java.io.OutputStream os) { if (null == os) { throw new java.lang.NullPointerException(); } LogManager.getLogManager().checkAccess(); close(true); this.writer = null; this.os = os; this.writerNotInitialized = true; }
public void store(java.io.Writer toWrite, String comments) { Kajabity.Tools.Java.JavaPropertyWriter reader = new Kajabity.Tools.Java.JavaPropertyWriter(this); reader.Write( new biz.ritter.io.StreamWrapper( null, new WriterOutputStream(toWrite) // better replace by converted Apache commons IO ), comments ); /* old but only with changes usable * Kajabity.Tools.Java.JavaPropertyWriter writer = new Kajabity.Tools.Java.JavaPropertyWriter(this); * writer.Write(toWrite, comments); */ }
// initialize the writer private void initializeWritter() { this.writerNotInitialized = false; if (null == getEncoding()) { this.writer = new java.io.OutputStreamWriter(this.os); } else { try { this.writer = new java.io.OutputStreamWriter(this.os, getEncoding()); } catch (java.io.UnsupportedEncodingException) { /* * Should not happen because it's checked in * super.initProperties(). */ } } write(getFormatter().getHead(this)); }
/** * Closes this handler, but the underlying output stream is only closed if * {@code closeStream} is {@code true}. Security is not checked. * * @param closeStream * whether to close the underlying output stream. */ protected void close(bool closeStream) { if (null != this.os) { if (this.writerNotInitialized) { initializeWritter(); } write(getFormatter().getTail(this)); try { this.writer.flush(); if (closeStream) { this.writer.close(); this.writer = null; this.os = null; } } catch (java.lang.Exception e) { // logging.15=Exception occurred when closing the output stream. getErrorManager().error("Exception occurred when closing the output stream.", e, //$NON-NLS-1$ ErrorManager.CLOSE_FAILURE); } } }
/** * Outputs this rpm in an XML format to the specified i/o writer. * * @param writer Writer stream. * @param excludePayload If this is true, the payload will not be included in the XML. * @throws IOException If an error occurred writing to the writer. */ public void toXML(java.io.Writer writer, bool excludePayload) {//throws IOException { // TODO }
/** * Sets the character encoding used by this handler. A {@code null} value * indicates that the default encoding should be used. * * @param encoding * the character encoding to set. * @throws SecurityException * if a security manager determines that the caller does not * have the required permission. * @throws UnsupportedEncodingException * if the specified encoding is not supported by the runtime. */ public virtual void setEncoding(String encoding) { // throws SecurityException, // UnsupportedEncodingException { // flush first before set new encoding this.flush(); base.setEncoding(encoding); // renew writer only if the writer exists if (null != this.writer) { if (null == getEncoding()) { this.writer = new java.io.OutputStreamWriter(this.os); } else { try { this.writer = new java.io.OutputStreamWriter(this.os, getEncoding()); } catch (java.io.UnsupportedEncodingException e) { /* * Should not happen because it's checked in * super.initProperties(). */ throw new java.lang.AssertionError(e); } } } }
public void store(java.io.Writer toWrite, String comments) { Kajabity.Tools.Java.JavaPropertyWriter writer = new Kajabity.Tools.Java.JavaPropertyWriter(this); writer.Write(toWrite, comments); }
// initialize the writer private void initializeWritter() { this.writerNotInitialized = false; if (null == getEncoding()) { this.writer = new java.io.OutputStreamWriter(this.os); } else { try { this.writer = new java.io.OutputStreamWriter(this.os, getEncoding()); } catch (java.io.UnsupportedEncodingException e) { /* * Should not happen because it's checked in * super.initProperties(). */ } } write(getFormatter().getHead(this)); }
public WriterOutputStream(java.io.Writer writer) { this.baseWriter = writer; }