org.apache.xml.serializer

Class WriterToASCI


public class WriterToASCI
extends Writer

This class writes ASCII to a byte stream as quickly as possible. For the moment it does not do buffering, though I reserve the right to do some buffering down the line if I can prove that it will be faster even if the output stream is buffered.

Constructor Summary

WriterToASCI(OutputStream os)
Create an unbuffered ASCII writer.

Method Summary

void
close()
Close the stream, flushing it first.
void
flush()
Flush the stream.
OutputStream
getOutputStream()
Get the output stream where the events will be serialized to.
void
write(String s)
Write a string.
void
write(chars[] , int start, int length)
Write a portion of an array of characters.
void
write(int c)
Write a single character.

Constructor Details

WriterToASCI

public WriterToASCI(OutputStream os)
Create an unbuffered ASCII writer.

Parameters:
os - The byte stream to write to.

Method Details

close

public void close()
            throws java.io.IOException
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.


flush

public void flush()
            throws java.io.IOException
Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.


getOutputStream

public OutputStream getOutputStream()
Get the output stream where the events will be serialized to.

Returns:
reference to the result stream, or null of only a writer was set.


write

public void write(String s)
            throws IOException
Write a string.

Parameters:


write

public void write(chars[] ,
                  int start,
                  int length)
            throws java.io.IOException
Write a portion of an array of characters.

Parameters:
start - Offset from which to start writing characters
length - Number of characters to write


write

public void write(int c)
            throws IOException
Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Subclasses that intend to support efficient single-character output should override this method.

Parameters:
c - int specifying a character to be written.


Copyright B) 2004 Apache XML Project. All Rights Reserved.