hudson.util
Class HeadBufferingStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by hudson.util.HeadBufferingStream
All Implemented Interfaces:
Closeable

public class HeadBufferingStream
extends FilterInputStream

FilterInputStream that buffers the first N bytes to a byte array on the side. This byte array can be then accessed later.

Useful for sniffing the content of the stream after the error is discovered.

Author:
Kohsuke Kawaguchi

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
HeadBufferingStream(InputStream in, int sideBufferSize)
           
 
Method Summary
 void fillSide()
          Read until we fill up the side buffer.
 byte[] getSideBuffer()
          Gets the side buffer content.
 int read()
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeadBufferingStream

public HeadBufferingStream(InputStream in,
                           int sideBufferSize)
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

fillSide

public void fillSide()
              throws IOException
Read until we fill up the side buffer.

Throws:
IOException

getSideBuffer

public byte[] getSideBuffer()
Gets the side buffer content.



Copyright © 2004-2013. All Rights Reserved.