All Packages  This Package  Class Hierarchy  Class Search  Index

Class glguerin.util.CaptureOutputStream
java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----java.io.FilterOutputStream
                   |
                   +----glguerin.util.CaptureOutputStream

  Summary

public class  CaptureOutputStream
     extends java.io.FilterOutputStream
{
          // Constructors 1
     public CaptureOutputStream(OutputStream, int);

          // Methods 3
     public byte[] getCaptured();
     public void write(byte[], int, int) throws IOException;
     public void write(int) throws IOException;
}

CaptureOutputStream is a FilterOutputStream that captures and retains the last N bytes written to it, where N is a constructor arg. A copy of the captured bytes can be returned at any time, even after close().

Bytes are NOT captured if the underlying OutputStream throws an IOException from its write().




  Constructors

· CaptureOutputStream

Summary  |  Top

   public CaptureOutputStream(OutputStream out, 
                              int N) 

Writes to OutputStream, capturing last N bytes written.



  Methods

· getCaptured

Summary  |  Top
   public byte[] getCaptured() 

Return a copy of the bytes most recently captured. This will be fewer than N in the constructor if less than N bytes have been written. This will be none (i.e. a zero-length byte[]) if no bytes have been written.



· write

Summary  |  Top
   public void write(int abyte)  throws IOException

Write one byte.

Overrides:
write in class FilterOutputStream


· write

Summary  |  Top
   public void write(byte[] bytes, 
                     int offset, 
                     int count)  throws IOException

Write range of byte-array.

Overrides:
write in class FilterOutputStream


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7