net.sf.jmatchparser.util.split
Class SplitOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.sf.jmatchparser.util.split.SplitOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class SplitOutputStream
extends OutputStream

Output stream that can split the output into multiple streams/files, and may optionally add a header and/or footer to each stream. A SplitRule is used to determine the split positions.


Nested Class Summary
static interface SplitOutputStream.StreamFactory
          Factory used to create new streams whenever the stream has to be split.
 
Constructor Summary
SplitOutputStream(SplitOutputStream.StreamFactory factory, SplitRule rule)
          Create a new split output stream.
 
Method Summary
 void close()
           
 void finishBlock()
          Finish a header or footer block.
 void flush()
           
 void startFooterBlock()
          Start the footer block.
 void startHeaderBlock()
          Start the header block.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitOutputStream

public SplitOutputStream(SplitOutputStream.StreamFactory factory,
                         SplitRule rule)
Create a new split output stream.

Parameters:
factory - Factory used to create streams
rule - Split rule to determine when to split the stream
Method Detail

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

startHeaderBlock

public void startHeaderBlock()
Start the header block. After calling this method, all output will be added to the header of each file, until finishBlock() is called.


startFooterBlock

public void startFooterBlock()
Start the footer block. After calling this method, all output will be added to the footer of each file, until finishBlock() is called.


finishBlock

public void finishBlock()
                 throws IOException
Finish a header or footer block.

Throws:
IOException
See Also:
startHeaderBlock(), startFooterBlock()

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException


Copyright © 2011. All Rights Reserved.