Class ByteArrayDataSink

  • All Implemented Interfaces:

    public final class ByteArrayDataSink
    extends Object
    implements DataSink
    A DataSink for writing to a byte array.
    • Constructor Detail

      • ByteArrayDataSink

        public ByteArrayDataSink()
    • Method Detail

      • open

        public void open​(DataSpec dataSpec)
        Description copied from interface: DataSink
        Opens the sink to consume the specified data.

        Note: If an IOException is thrown, callers must still call DataSink.close() to ensure that any partial effects of the invocation are cleaned up.

        Specified by:
        open in interface DataSink
        dataSpec - Defines the data to be consumed.
      • write

        public void write​(byte[] buffer,
                          int offset,
                          int length)
        Description copied from interface: DataSink
        Consumes the provided data.
        Specified by:
        write in interface DataSink
        buffer - The buffer from which data should be consumed.
        offset - The offset of the data to consume in buffer.
        length - The length of the data to consume, in bytes.
      • getData

        public byte[] getData()
        Returns the data written to the sink since the last call to open(DataSpec), or null if open(DataSpec) has never been called.