类 RandomAccessDataFile
- java.lang.Object
- org.springframework.boot.loader.data.RandomAccessDataFile
- 所有已实现的接口:
RandomAccessData
public class RandomAccessDataFile extends Object implements RandomAccessData
RandomAccessData
implementation backed by aRandomAccessFile
.
构造器概要
构造器 构造器 说明 RandomAccessDataFile(File file)
Create a newRandomAccessDataFile
backed by the specified file.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
File
getFile()
Returns the underlying File.InputStream
getInputStream()
Returns anInputStream
that can be used to read the underlying data.long
getSize()
Returns the size of the data.RandomAccessData
getSubsection(long offset, long length)
Returns a newRandomAccessData
for 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 thelength
bytes of data starting at the givenoffset
.
构造器详细资料
RandomAccessDataFile
public RandomAccessDataFile(File file)
Create a newRandomAccessDataFile
backed by the specified file.- 参数:
file
- the underlying file- 抛出:
IllegalArgumentException
- if the file is null or does not exist
方法详细资料
getInputStream
public InputStream getInputStream() throws IOException
从接口复制的说明:RandomAccessData
Returns anInputStream
that 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)
从接口复制的说明:RandomAccessData
Returns a newRandomAccessData
for 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
从接口复制的说明:RandomAccessData
Reads 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
从接口复制的说明:RandomAccessData
Reads thelength
bytes 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()
从接口复制的说明:RandomAccessData
Returns the size of the data.- 指定者:
getSize
在接口中RandomAccessData
- 返回:
- the size
close
public void close() throws IOException
- 抛出:
IOException