public class RereadableInputStream extends InputStream
Constructor and Description |
---|
RereadableInputStream(InputStream inputStream)
Creates a rereadable input stream with defaults of 512*1024*1024 bytes (500M) for
maxBytesInMemory and both readToEndOfStreamOnFirstRewind and closeOriginalStreamOnClose
set to true
|
RereadableInputStream(InputStream inputStream,
boolean closeOriginalStreamOnClose)
Creates a rereadable input stream defaulting to 512*1024*1024 bytes (500M) for
maxBytesInMemory
|
RereadableInputStream(InputStream inputStream,
int maxBytesInMemory)
Creates a rereadable input stream with closeOriginalStreamOnClose set to true
|
RereadableInputStream(InputStream inputStream,
int maxBytesInMemory,
boolean closeOriginalStreamOnClose)
Creates a rereadable input stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the input stream and removes the temporary file if one was
created.
|
int |
read()
Reads a byte from the stream, saving it in the store if it is being
read from the original stream.
|
void |
rewind()
"Rewinds" the stream to the beginning for rereading.
|
available, mark, markSupported, read, read, reset, skip
public RereadableInputStream(InputStream inputStream)
inputStream
- stream containing the source of datapublic RereadableInputStream(InputStream inputStream, boolean closeOriginalStreamOnClose)
inputStream
- stream containing the source of datapublic RereadableInputStream(InputStream inputStream, int maxBytesInMemory)
inputStream
- stream containing the source of datamaxBytesInMemory
- maximum number of bytes to use to store
the stream's contents in memory before switching to disk; note that
the instance will preallocate a byte array whose size is
maxBytesInMemory. This byte array will be made available for
garbage collection (i.e. its reference set to null) when the
content size exceeds the array's size, when close() is called, or
when there are no more references to the instance.public RereadableInputStream(InputStream inputStream, int maxBytesInMemory, boolean closeOriginalStreamOnClose)
inputStream
- stream containing the source of datamaxBytesInMemory
- maximum number of bytes to use to store
the stream's contents in memory before switching to disk; note that
the instance will preallocate a byte array whose size is
maxBytesInMemory. This byte array will be made available for
garbage collection (i.e. its reference set to null) when the
content size exceeds the array's size, when close() is called, or
when there are no more references to the instance.public int read() throws IOException
read
in class InputStream
IOException
public void rewind() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.