Class ChunkInputStreamOptionalBuffer
java.lang.Object
java.io.InputStream
io.clonecloudstore.common.quarkus.stream.ChunkInputStreamOptionalBuffer
- All Implemented Interfaces:
ChunkInputStreamInterface
,Closeable
,AutoCloseable
public class ChunkInputStreamOptionalBuffer
extends InputStream
implements ChunkInputStreamInterface
Transform one InputStream to Multiple InputStream, each one being a chunk of the primary one.
Note that if length is not provided, chunk size will be the buffer size used internally, so the buffer size will be reduced to 512 MB for memory capacity handling. Inversely, if length is provided, no buffer will be allocated.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChunkInputStreamOptionalBuffer
(InputStream inputStream, long len, int chunkSize) -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
long
long
int
long
boolean
boolean
boolean
int
read()
int
read
(byte[] b, int off, int len) long
skip
(long len) long
transferTo
(OutputStream out) Methods inherited from class java.io.InputStream
mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes
-
Field Details
-
MIN_CHUNK_SIZE
public static final int MIN_CHUNK_SIZE- See Also:
-
maxChunkSize
public final int maxChunkSize
-
-
Constructor Details
-
ChunkInputStreamOptionalBuffer
- Parameters:
inputStream
- the InputStream to split as multiple InputStream by chunklen
- the real InputStream size; if 0, chunk size will be the buffer size usedchunkSize
- the chunk size to split on
-
-
Method Details
-
nextChunk
- Specified by:
nextChunk
in interfaceChunkInputStreamInterface
- Returns:
- True if the next Chunk of InputStream is ready, else implies closing of native InputStream
- Throws:
IOException
- if an issue occurs
-
isChunksDone
public boolean isChunksDone()- Specified by:
isChunksDone
in interfaceChunkInputStreamInterface
- Returns:
- True if all chunks are done
-
getAvailableChunkSize
public long getAvailableChunkSize()- Specified by:
getAvailableChunkSize
in interfaceChunkInputStreamInterface
- Returns:
- if known, the chunk size currently available, else -1
-
getChunkSize
public long getChunkSize()- Specified by:
getChunkSize
in interfaceChunkInputStreamInterface
- Returns:
- the current chunk size
-
getCurrentPos
public int getCurrentPos()- Specified by:
getCurrentPos
in interfaceChunkInputStreamInterface
- Returns:
- the current position in the buffer
-
getCurrentTotalRead
public long getCurrentTotalRead()- Specified by:
getCurrentTotalRead
in interfaceChunkInputStreamInterface
- Returns:
- the total number of read bytes
-
read
- Specified by:
read
in interfaceChunkInputStreamInterface
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in interfaceChunkInputStreamInterface
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Specified by:
skip
in interfaceChunkInputStreamInterface
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Specified by:
available
in interfaceChunkInputStreamInterface
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChunkInputStreamInterface
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Specified by:
markSupported
in interfaceChunkInputStreamInterface
- Overrides:
markSupported
in classInputStream
-
transferTo
- Specified by:
transferTo
in interfaceChunkInputStreamInterface
- Overrides:
transferTo
in classInputStream
- Throws:
IOException
-