类 RandomAccessDataFile
- java.lang.Object
- org.springframework.boot.loader.data.RandomAccessDataFile
- 所有已实现的接口:
RandomAccessData
public class RandomAccessDataFile extends Object implements RandomAccessData
RandomAccessDataimplementation backed by aRandomAccessFile.
构造器概要
构造器 构造器 说明 RandomAccessDataFile(File file)Create a newRandomAccessDataFilebacked by the specified file.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidclose()FilegetFile()Returns the underlying File.InputStreamgetInputStream()Returns anInputStreamthat can be used to read the underlying data.longgetSize()Returns the size of the data.RandomAccessDatagetSubsection(long offset, long length)Returns a newRandomAccessDatafor a specific subsection of this data.byte[]read()Reads all the data and returns it as a byte array.byte[]read(long offset, long length)Reads thelengthbytes of data starting at the givenoffset.
构造器详细资料
RandomAccessDataFile
public RandomAccessDataFile(File file)
Create a newRandomAccessDataFilebacked by the specified file.- 参数:
file- the underlying file- 抛出:
IllegalArgumentException- if the file is null or does not exist
方法详细资料
getInputStream
public InputStream getInputStream() throws IOException
从接口复制的说明:RandomAccessDataReturns anInputStreamthat can be used to read the underlying data. The caller is responsible close the underlying stream.- 指定者:
getInputStream在接口中RandomAccessData- 返回:
- a new input stream that can be used to read the underlying data.
- 抛出:
IOException- if the stream cannot be opened
getSubsection
public RandomAccessData getSubsection(long offset, long length)
从接口复制的说明:RandomAccessDataReturns a newRandomAccessDatafor a specific subsection of this data.- 指定者:
getSubsection在接口中RandomAccessData- 参数:
offset- the offset of the subsectionlength- the length of the subsection- 返回:
- the subsection data
read
public byte[] read() throws IOException
从接口复制的说明:RandomAccessDataReads all the data and returns it as a byte array.- 指定者:
read在接口中RandomAccessData- 返回:
- the data
- 抛出:
IOException- if the data cannot be read
read
public byte[] read(long offset, long length) throws IOException
从接口复制的说明:RandomAccessDataReads thelengthbytes of data starting at the givenoffset.- 指定者:
read在接口中RandomAccessData- 参数:
offset- the offset from which data should be readlength- the number of bytes to be read- 返回:
- the data
- 抛出:
IOException- if the data cannot be readEOFException- if offset plus length is greater than the length of the file or subsection
getSize
public long getSize()
从接口复制的说明:RandomAccessDataReturns the size of the data.- 指定者:
getSize在接口中RandomAccessData- 返回:
- the size
close
public void close() throws IOException
- 抛出:
IOException