public class RandomAccessDataFile extends Object implements RandomAccessData
RandomAccessData
implementation backed by a RandomAccessFile
.RandomAccessData.ResourceAccess
Constructor and Description |
---|
RandomAccessDataFile(File file)
Create a new
RandomAccessDataFile backed by the specified file. |
RandomAccessDataFile(File file,
int concurrentReads)
Create a new
RandomAccessDataFile backed by the specified file. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
File |
getFile()
Returns the underling File.
|
InputStream |
getInputStream(RandomAccessData.ResourceAccess access)
Returns an
InputStream that can be used to read the underling data. |
long |
getSize()
Returns the size of the data.
|
RandomAccessData |
getSubsection(long offset,
long length)
Returns a new
RandomAccessData for a specific subsection of this data. |
public RandomAccessDataFile(File file)
RandomAccessDataFile
backed by the specified file.file
- the underlying fileIllegalArgumentException
- if the file is null or does not existRandomAccessDataFile(File, int)
public RandomAccessDataFile(File file, int concurrentReads)
RandomAccessDataFile
backed by the specified file.file
- the underlying fileconcurrentReads
- the maximum number of concurrent reads allowed on the
underlying file before blockingIllegalArgumentException
- if the file is null or does not existRandomAccessDataFile(File)
public File getFile()
public InputStream getInputStream(RandomAccessData.ResourceAccess access) throws IOException
RandomAccessData
InputStream
that can be used to read the underling data. The
caller is responsible close the underlying stream.getInputStream
in interface RandomAccessData
access
- hint indicating how the underlying data should be accessedIOException
- if the stream cannot be openedpublic RandomAccessData getSubsection(long offset, long length)
RandomAccessData
RandomAccessData
for a specific subsection of this data.getSubsection
in interface RandomAccessData
offset
- the offset of the subsectionlength
- the length of the subsectionpublic long getSize()
RandomAccessData
getSize
in interface RandomAccessData
public void close() throws IOException
IOException
Copyright © 2015 Pivotal Software, Inc.. All rights reserved.