Class RadInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class RadInputStream
    extends InputStream
    InputStream based on a RandomAccessData data source. It provides a view to a subregion of the underlying data source through an InputStream. The usage would happen typically in two stages:
    1. Use a RandomAccessData instance directly to efficiently locate offset and length of the embedded data.
    2. Create a RadInputStream object on the RandomAccessData instance to access the embedded data through an InputStream.
    Example:
    
     RandomAccessData randomAccessData = RandomAccessDataFactory.createInstance(...);
     X3fImageData imageData = ...
     try (InputStream is = new RadInputStream(
            randomAccessData, imageData.getDataOffset(), imageData.getDataLength()))
     {
            ...
     }
     
    • Method Detail

      • isClosed

        public boolean isClosed()
        Returns true, if this stream has been closed.
        Returns:
        true, if this stream has been closed
      • close

        public void close()
        Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Note, that this method does not close the underlying RandomAccessData object.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class InputStream
      • mark

        public void mark​(int readlimit)
        Remembers the current position of this stream. No data will be remembered. That is, after a call to reset(), subsequent reads may or may not re-read the same data, if the underlying data source has been written to.
        Overrides:
        mark in class InputStream
        Parameters:
        readlimit - has no effect for this stream type
      • markSupported

        public boolean markSupported()
        This input stream does not support marking with remembering of data. It does however support efficient repositioning and skipping within the data source.
        Overrides:
        markSupported in class InputStream
        Returns:
        false
      • reset

        public void reset()
                   throws IOException
        Repositions this stream to the last marked position. It does not remember any data, that is, subsequent reads may or may not re-read the same data, if the underlying data source has been written to.
        Overrides:
        reset in class InputStream
        Throws:
        IOException - if an error occurs during I/O operation
      • skip

        public long skip​(long n)
                  throws IOException
        Seeks efficiently relative to the current position to any offset within the data source. It is possible to jump backwards with negative values.
        Overrides:
        skip in class InputStream
        Parameters:
        n - the number of bytes to seek, negative value to jump backwards
        Returns:
        the number of bytes actually skipped
        Throws:
        IOException - if an error occurs during I/O operation