|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.io.OutputStreamMerger
public class OutputStreamMerger
Output stream funnel. Merges the output of one or more output streams into the same underlying output stream.
Data written to any of the source streams for this object is merged together and written to the single output (sink) stream of this object. This acts like a funnel, combining the output data from several source streams into a single output stream. This can be useful when several threads are writing to a single text file simultaneously.
Copyright ©2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by
by the United States Department of State as a terrorist, or terrorist
government or agency, to use and distribute this source code provided
that the original copyright notice remains present and unaltered.
Field Summary | |
---|---|
static int |
EOLN_NATIVE
Indicates that the native end-of-line character is used. |
static int |
EOLN_NONE
Indicates that no end-of-line character is used. |
(package private) static java.lang.String |
REV
|
Constructor Summary | |
---|---|
OutputStreamMerger(java.io.OutputStream out)
Constructs a multiple output stream funnel with no source streams. |
Method Summary | |
---|---|
void |
close()
Close the underlying output stream. |
void |
flush()
Flush any pending output to the underlying output stream. |
java.io.OutputStream |
getSource()
Create a source output stream that writes merged data to the underlying output stream of this object. |
java.io.OutputStream |
getSource(int eoln,
boolean autoFlush,
int bufSize)
Create a source output stream that writes merged data to the underlying output stream of this object. |
(package private) void |
writeBytes(byte[] buf,
int off,
int len)
Write a set of bytes to the underlying output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
public static final int EOLN_NONE
public static final int EOLN_NATIVE
Constructor Detail |
---|
public OutputStreamMerger(java.io.OutputStream out)
Method getSource()
is called to create one or more
source streams for this object's output stream. All data written to the
source streams is merged and written to the single underlying output
stream.
out
- The underlying output stream, to which all the data written to the source
streams associated with this object is written.Method Detail |
---|
public java.io.OutputStream getSource(int eoln, boolean autoFlush, int bufSize)
Note that each call to this method creates a new independent data source for the underlying output stream.
eoln
- End-of-line character code for the buffered output stream.
All output written to the stream is buffered by lines, and is only written
when the internal line buffer becomes full or when an end-of-line
character code is written.
If this is equal to EOLN_NATIVE
, the native end-of-line character
for the underlying operating system is used.
Is this is equal to EOLN_NONE
, no end-of-line character is used,
and output is written only when the internal line buffer becomes full.
autoFlush
- If true, the underlying output stream is flushed (see flush()
)
whenever the flush() method of the source stream is called;
otherwise, only the internal line buffer of the source stream is flushed
to the underlying output stream.
bufSize
- Size (in bytes) of the internal line buffer.
If this is zero or negative, the default size of 1024 bytes is used.
public java.io.OutputStream getSource()
getSource
(EOLN_NATIVE
, false, 0)
public void flush() throws java.io.IOException
java.io.IOException
- Thrown if an I/O (write) error occurs on the underlying output stream.public void close() throws java.io.IOException
Note that this method can be called multiple times without any ill effects.
java.io.IOException
- Thrown if an I/O error occurs on the underlying output stream.void writeBytes(byte[] buf, int off, int len) throws java.io.IOException
buf
- An array of bytes to be written.
off
- Index of the first byte in buf to write.
len
- Number of bytes in buf to write.
java.io.IOException
- Thrown if an I/O (write) error occurs on the underlying output stream.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |