Class RandomAccessDataFile
- java.lang.Object
-
- fish.payara.micro.boot.loader.data.RandomAccessDataFile
-
- All Implemented Interfaces:
RandomAccessData
public class RandomAccessDataFile extends Object implements RandomAccessData
RandomAccessDataimplementation backed by aRandomAccessFile.- Author:
- Phillip Webb
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface fish.payara.micro.boot.loader.data.RandomAccessData
RandomAccessData.ResourceAccess
-
-
Constructor Summary
Constructors Constructor Description RandomAccessDataFile(File file)Create a newRandomAccessDataFilebacked by the specified file.RandomAccessDataFile(File file, int concurrentReads)Create a newRandomAccessDataFilebacked by the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()FilegetFile()Returns the underlying File.InputStreamgetInputStream(RandomAccessData.ResourceAccess access)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.
-
-
-
Constructor Detail
-
RandomAccessDataFile
public RandomAccessDataFile(File file)
Create a newRandomAccessDataFilebacked by the specified file.- Parameters:
file- the underlying file- Throws:
IllegalArgumentException- if the file is null or does not exist- See Also:
RandomAccessDataFile(File, int)
-
RandomAccessDataFile
public RandomAccessDataFile(File file, int concurrentReads)
Create a newRandomAccessDataFilebacked by the specified file.- Parameters:
file- the underlying fileconcurrentReads- the maximum number of concurrent reads allowed on the underlying file before blocking- Throws:
IllegalArgumentException- if the file is null or does not exist- See Also:
RandomAccessDataFile(File)
-
-
Method Detail
-
getFile
public File getFile()
Returns the underlying File.- Returns:
- the underlying file
-
getInputStream
public InputStream getInputStream(RandomAccessData.ResourceAccess access) throws IOException
Description copied from interface:RandomAccessDataReturns anInputStreamthat can be used to read the underlying data. The caller is responsible close the underlying stream.- Specified by:
getInputStreamin interfaceRandomAccessData- Parameters:
access- hint indicating how the underlying data should be accessed- 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:RandomAccessDataReturns a newRandomAccessDatafor a specific subsection of this data.- Specified by:
getSubsectionin interfaceRandomAccessData- Parameters:
offset- the offset of the subsectionlength- the length of the subsection- Returns:
- the subsection data
-
getSize
public long getSize()
Description copied from interface:RandomAccessDataReturns the size of the data.- Specified by:
getSizein interfaceRandomAccessData- Returns:
- the size
-
close
public void close() throws IOException- Throws:
IOException
-
-