Package hudson.util
Class HeadBufferingStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- hudson.util.HeadBufferingStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
Constructors Constructor Description HeadBufferingStream(InputStream in, int sideBufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
HeadBufferingStream
public HeadBufferingStream(InputStream in, int sideBufferSize)
-
-
Method Detail
-
read
public int read() throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classFilterInputStream
- 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.
-
-