public class ContentInfoInputStreamWrapper extends InputStream
InputStream
. This allows you to read from an input stream and then
after you are done, call findMatch()
to determine the content-type information of the bytes read.
NOTE: This keeps a buffer of the first ContentInfoUtil.DEFAULT_READ_SIZE
(maybe 10k) bytes read or
skipped to determine the content-type of the bytes read.
Constructor and Description |
---|
ContentInfoInputStreamWrapper(InputStream delegate)
Create a stream wrapper while using the internal, static ContentInfoUtil.
|
ContentInfoInputStreamWrapper(InputStream delegate,
ContentInfoUtil contentInfoUtil)
Create a stream wrapper while specifying your own ContentInfoUtil.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
ContentInfo |
findMatch()
Find a match from the bytes that have been read from the stream using
ContentInfoUtil.findMatch(byte[]) . |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long skipNum) |
read
public ContentInfoInputStreamWrapper(InputStream delegate, ContentInfoUtil contentInfoUtil)
public ContentInfoInputStreamWrapper(InputStream delegate)
public ContentInfo findMatch()
ContentInfoUtil.findMatch(byte[])
.public int available() throws IOException
available
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long skipNum) throws IOException
skip
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.