Class ObjectPlusFilesInputStream

java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
org.archive.io.ObjectPlusFilesInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

public class ObjectPlusFilesInputStream extends ObjectInputStream
Enhanced ObjectOutputStream with support for restoring files that had been saved, in parallel with object serialization.
Author:
gojomo
  • Field Details

  • Constructor Details

    • ObjectPlusFilesInputStream

      public ObjectPlusFilesInputStream(InputStream in, File storeDir) throws IOException
      Instantiate over the given stream and using the supplied auxiliary storage directory.
      Parameters:
      in -
      storeDir -
      Throws:
      IOException
  • Method Details

    • pushAuxiliaryDirectory

      public void pushAuxiliaryDirectory(String dir)
      Push another default storage directory for use until popped.
      Parameters:
      dir -
    • popAuxiliaryDirectory

      public void popAuxiliaryDirectory()
      Discard the top auxiliary directory.
    • getAuxiliaryDirectory

      public File getAuxiliaryDirectory()
      Return the top auxiliary directory, from which saved files are restored.
      Returns:
      Auxillary directory.
    • restoreFile

      public void restoreFile(File destination) throws IOException
      Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.
      Parameters:
      destination -
      Throws:
      IOException
    • restoreFileTo

      public void restoreFileTo(File directory) throws IOException
      Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.
      Parameters:
      directory -
      Throws:
      IOException
    • registerFinishTask

      public void registerFinishTask(Runnable task)
      Register a task to be done when the ObjectPlusFilesInputStream is closed.
      Parameters:
      task -
    • close

      public void close() throws IOException
      In addition to default, do any registered cleanup tasks.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ObjectInput
      Overrides:
      close in class ObjectInputStream
      Throws:
      IOException
      See Also: