donaldp 2003/02/26 00:23:02
Modified: src/java/org/apache/log/output/io StreamTarget.java
Log:
Add mechanism via which to set the encoding which will be used to write out data.
Submitted By: [EMAIL PROTECTED]
Revision Changes Path
1.9 +23 -3
avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java
Index: StreamTarget.java
===================================================================
RCS file:
/home/cvs/avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StreamTarget.java 9 Feb 2003 23:33:23 -0000 1.8
+++ StreamTarget.java 26 Feb 2003 08:23:02 -0000 1.9
@@ -67,18 +67,27 @@
public class StreamTarget
extends AbstractOutputTarget
{
+ ///Default character encoding
+ private static final String DEFAULT_ENCODING = "US-ASCII";
+
///OutputStream we are writing to
private OutputStream m_outputStream;
+ //The encoding to use when creating byte array for string
+ private String m_encoding;
+
/**
* Constructor that writes to a stream and uses a particular formatter.
*
* @param outputStream the OutputStream to write to
* @param formatter the Formatter to use
*/
- public StreamTarget( final OutputStream outputStream, final Formatter formatter
)
+ public StreamTarget( final OutputStream outputStream,
+ final Formatter formatter,
+ final String encoding )
{
super( formatter );
+ m_encoding = encoding;
if( null != outputStream )
{
@@ -88,6 +97,18 @@
}
/**
+ * Constructor that writes to a stream and uses a particular formatter.
+ *
+ * @param outputStream the OutputStream to write to
+ * @param formatter the Formatter to use
+ */
+ public StreamTarget( final OutputStream outputStream,
+ final Formatter formatter )
+ {
+ this( outputStream, formatter, DEFAULT_ENCODING );
+ }
+
+ /**
* Set the output stream.
* Close down old stream and write tail if appropriate.
*
@@ -123,8 +144,7 @@
try
{
- //TODO: We should be able to specify encoding???
- outputStream.write( data.getBytes() );
+ outputStream.write( data.getBytes( m_encoding ) );
outputStream.flush();
}
catch( final IOException ioe )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]