Interface DataBlock

All Known Subinterfaces:
CloseableDataBlock

public interface DataBlock
Provides read access to a block of data contained somewhere in a zip file.
Since:
3.2.0
Author:
Phillip Webb
  • Method Summary

    Modifier and Type
    Method
    Description
    default InputStream
    Return this DataBlock as an InputStream.
    int
    read(ByteBuffer dst, long pos)
    Read a sequence of bytes from this channel into the given buffer, starting at the given block position.
    default void
    readFully(ByteBuffer dst, long pos)
    Fully read a sequence of bytes from this channel into the given buffer, starting at the given block position and filling remaining bytes in the buffer.
    long
    Return the size of this block.
  • Method Details

    • size

      long size() throws IOException
      Return the size of this block.
      Returns:
      the block size
      Throws:
      IOException - on I/O error
    • read

      int read(ByteBuffer dst, long pos) throws IOException
      Read a sequence of bytes from this channel into the given buffer, starting at the given block position.
      Parameters:
      dst - the buffer into which bytes are to be transferred
      pos - the position within the block at which the transfer is to begin
      Returns:
      the number of bytes read, possibly zero, or -1 if the given position is greater than or equal to the block size
      Throws:
      IOException - on I/O error
      See Also:
    • readFully

      default void readFully(ByteBuffer dst, long pos) throws IOException
      Fully read a sequence of bytes from this channel into the given buffer, starting at the given block position and filling remaining bytes in the buffer.
      Parameters:
      dst - the buffer into which bytes are to be transferred
      pos - the position within the block at which the transfer is to begin
      Throws:
      EOFException - if an attempt is made to read past the end of the block
      IOException - on I/O error
    • asInputStream

      default InputStream asInputStream() throws IOException
      Return this DataBlock as an InputStream.
      Returns:
      an InputStream to read the data block content
      Throws:
      IOException - on IO error