Package org.jppf.location
Class FileLocation
- All Implemented Interfaces:
Serializable,Location<String>
Wrapper for manipulating a file.
This implementation of the
Location interface allows writing to and reading from a file.- Author:
- Laurent Cohen
- See Also:
-
Field Summary
Fields inherited from class org.jppf.location.AbstractLocation
eventsEnabled, listeners, path -
Constructor Summary
ConstructorsConstructorDescriptionFileLocation(File file) Initialize this location with the specified file path.FileLocation(String file) Initialize this location with the specified file path. -
Method Summary
Modifier and TypeMethodDescriptionObtain an input stream to read from this location.Obtain an output stream to write to this location.longsize()Get the size of the file this location points to.Methods inherited from class org.jppf.location.AbstractLocation
addLocationEventListener, copyTo, fireLocationEvent, getPath, removeLocationEventListener, toByteArray, toString
-
Constructor Details
-
FileLocation
Initialize this location with the specified file path.Warning: if this file location is intended for use on a remote machine, then you should use
FileLocation(String)instead, since this constructor computes the path as the system-dependentcanonical pathof the argument.- Parameters:
file- an abstract file path.- Throws:
IOException- if any I/O error occurs.
-
FileLocation
Initialize this location with the specified file path.- Parameters:
file- a string representing the file path.
-
-
Method Details
-
getInputStream
Description copied from interface:LocationObtain an input stream to read from this location.- Returns:
- an
InputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
getOutputStream
Description copied from interface:LocationObtain an output stream to write to this location.- Returns:
- an
OutputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
size
public long size()Get the size of the file this location points to.- Returns:
- the size as a long value, or -1 if the file does not exist.
-