Class RandomAccessDataFile

java.lang.Object
org.springframework.boot.loader.data.RandomAccessDataFile
All Implemented Interfaces:
RandomAccessData

public class RandomAccessDataFile extends Object implements RandomAccessData
RandomAccessData implementation backed by a RandomAccessFile.
Since:
1.0.0
Author:
Phillip Webb, Andy Wilkinson
  • Constructor Details

  • Method Details

    • getFile

      public File getFile()
      Returns the underlying File.
      Returns:
      the underlying file
    • getInputStream

      public InputStream getInputStream() throws IOException
      Description copied from interface: RandomAccessData
      Returns an InputStream that can be used to read the underlying data. The caller is responsible close the underlying stream.
      Specified by:
      getInputStream in interface RandomAccessData
      Returns:
      a new input stream that can be used to read the underlying data.
      Throws:
      IOException - if the stream cannot be opened
    • getSubsection

      public RandomAccessData getSubsection(long offset, long length)
      Description copied from interface: RandomAccessData
      Returns a new RandomAccessData for a specific subsection of this data.
      Specified by:
      getSubsection in interface RandomAccessData
      Parameters:
      offset - the offset of the subsection
      length - the length of the subsection
      Returns:
      the subsection data
    • read

      public byte[] read() throws IOException
      Description copied from interface: RandomAccessData
      Reads all the data and returns it as a byte array.
      Specified by:
      read in interface RandomAccessData
      Returns:
      the data
      Throws:
      IOException - if the data cannot be read
    • read

      public byte[] read(long offset, long length) throws IOException
      Description copied from interface: RandomAccessData
      Reads the length bytes of data starting at the given offset.
      Specified by:
      read in interface RandomAccessData
      Parameters:
      offset - the offset from which data should be read
      length - the number of bytes to be read
      Returns:
      the data
      Throws:
      IOException - if the data cannot be read
      EOFException - if offset plus length is greater than the length of the file or subsection
    • getSize

      public long getSize()
      Description copied from interface: RandomAccessData
      Returns the size of the data.
      Specified by:
      getSize in interface RandomAccessData
      Returns:
      the size
    • close

      public void close() throws IOException
      Throws:
      IOException