org.springframework.boot.loader.data
Class RandomAccessDataFile

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

public class RandomAccessDataFile
extends Object
implements RandomAccessData

RandomAccessData implementation backed by a RandomAccessFile.

Author:
Phillip Webb

Constructor Summary
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.
 
Method Summary
 void close()
           
 File getFile()
          Returns the underling File.
 InputStream getInputStream()
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessDataFile

public RandomAccessDataFile(File file)
Create a new RandomAccessDataFile backed 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 new RandomAccessDataFile backed by the specified file.

Parameters:
file - the underlying file
concurrentReads - 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 underling File.

Returns:
the underlying file

getInputStream

public InputStream getInputStream()
Description copied from interface: RandomAccessData
Returns an InputStream that can be used to read the underling 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.

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

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


Copyright © 2013. All Rights Reserved.