Package org.jppf.io

Class FileDataLocation

All Implemented Interfaces:
DataLocation

public class FileDataLocation extends AbstractDataLocation
Data location backed by a file.
Author:
Laurent Cohen, Juan Manuel Rodriguez
  • Constructor Details

    • FileDataLocation

      public FileDataLocation(String path)
      Initialize this file location with the specified file path and an unknown size.
      Parameters:
      path - the path to the underlying file.
    • FileDataLocation

      public FileDataLocation(String path, int size)
      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

      public FileDataLocation(File file)
      Initialize this file location with the specified file and unknown size.
      Parameters:
      file - an abstract path to the underlying file.
    • FileDataLocation

      public FileDataLocation(File file, int size)
      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

      public int transferFrom(InputSource source, boolean blocking) throws Exception
      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

      public int transferTo(OutputDestination dest, boolean blocking) throws Exception
      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

      protected void finalize() throws Throwable
      This method deletes the underlying file.
      Overrides:
      finalize in class Object
      Throws:
      Throwable - if an error occurs.
    • getInputStream

      public InputStream getInputStream() throws Exception
      Get an input stream for this location.
      Returns:
      an InputStream instance.
      Throws:
      Exception - if an I/O error occurs.
    • getOutputStream

      public OutputStream getOutputStream() throws Exception
      Get an output stream for this location.
      Returns:
      an OutputStream instance.
      Throws:
      Exception - if an I/O error occurs.
    • copy

      public DataLocation 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

      public String getFilePath()
      Get the path to the underlying file.
      Returns:
      the path as a string.