Package org.jppf.io
Class FileDataLocation
java.lang.Object
org.jppf.io.AbstractDataLocation
org.jppf.io.FileDataLocation
- All Implemented Interfaces:
DataLocation
Data location backed by a file.
- Author:
- Laurent Cohen, Juan Manuel Rodriguez
-
Field Summary
Fields inherited from class org.jppf.io.AbstractDataLocation
size, transferringFields inherited from interface org.jppf.io.DataLocation
UNKNOWN_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionFileDataLocation(File file) Initialize this file location with the specified file and unknown size.FileDataLocation(File file, int size) Initialize this file location with the specified file and size.FileDataLocation(String path) Initialize this file location with the specified file path and an unknown size.FileDataLocation(String path, int size) Initialize this file location with the specified file path and size. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Make a shallow copy of this data location.protected voidfinalize()This method deletes the underlying file.Get the path to the underlying file.Get an input stream for this location.Get an output stream for this location.inttransferFrom(InputSource source, boolean blocking) Transfer the content of this data location from the specified input source.inttransferTo(OutputDestination dest, boolean blocking) Transfer the content of this data location to the specified output destination.Methods inherited from class org.jppf.io.AbstractDataLocation
getSize, setSize
-
Constructor Details
-
FileDataLocation
Initialize this file location with the specified file path and an unknown size.- Parameters:
path- the path to the underlying file.
-
FileDataLocation
Initialize this file location with the specified file path and size.- Parameters:
path- the path to the underlying file.size- the size of the data represented by this file location.
-
FileDataLocation
Initialize this file location with the specified file and unknown size.- Parameters:
file- an abstract path to the underlying file.
-
FileDataLocation
Initialize this file location with the specified file and size.- Parameters:
file- an abstract path to the underlying file.size- the size of the data represented by this file location.
-
-
Method Details
-
transferFrom
Transfer the content of this data location from the specified input source.- Parameters:
source- the input source to transfer from.blocking- if true, the method will block until the entire content has been transferred.- Returns:
- the number of bytes actually transferred.
- Throws:
Exception- if an IO error occurs.
-
transferTo
Transfer the content of this data location to the specified output destination.- Parameters:
dest- the output destination to transfer to.blocking- if true, the method will block until the entire content has been transferred.- Returns:
- the number of bytes actually transferred.
- Throws:
Exception- if an IO error occurs.
-
finalize
This method deletes the underlying file. -
getInputStream
Get an input stream for this location.- Returns:
- an
InputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
getOutputStream
Get an output stream for this location.- Returns:
- an
OutputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
copy
Make a shallow copy of this data location. The data it points to is not copied.- Returns:
- a new DataLocation instance pointing to the same data.
-
getFilePath
Get the path to the underlying file.- Returns:
- the path as a string.
-