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 Details

    • ChunkInputStream

      public ChunkInputStream(String chunkId, InputStream inputStream, long chunkSize, boolean preserveMD5)
  • Method Details

    • read

      public int read() throws IOException
      This 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:
      read in class InputStream
      Returns:
      current byte or -1 if eof reached
      Throws:
      IOException - on error
    • read

      public int read(byte[] b) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      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()