Package org.duracloud.chunk.stream
Class ChunkInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.duracloud.chunk.stream.ChunkInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ChunkInputStream extends InputStream
This class provides the ability to limit the number of bytes read from the provided InputStream to maxChunkSize.- Author:
- Andrew Woods Date: Feb 2, 2010
-
-
Constructor Summary
Constructors Constructor Description ChunkInputStream(String chunkId, InputStream inputStream, long chunkSize, boolean preserveMD5)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()StringgetChunkId()longgetChunkSize()StringgetMD5()StringgetMimetype()booleanmd5Preserved()longnumBytesRead()intread()This method reads up to chunkSize number of bytes from the stream.intread(byte[] b)intread(byte[] b, int off, int len)-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
ChunkInputStream
public ChunkInputStream(String chunkId, InputStream inputStream, long chunkSize, boolean preserveMD5)
-
-
Method Detail
-
read
public int read() throws IOExceptionThis method reads up to chunkSize number of bytes from the stream. When either chunkSize bytes have been read, or the end of the stream is reached, -1 is return.- Specified by:
readin classInputStream- Returns:
- current byte or -1 if eof reached
- Throws:
IOException- on error
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getMD5
public String getMD5()
-
numBytesRead
public long numBytesRead()
-
getChunkId
public String getChunkId()
-
getMimetype
public String getMimetype()
-
getChunkSize
public long getChunkSize()
-
md5Preserved
public boolean md5Preserved()
-
-