Class ObjectPlusFilesOutputStream

java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
org.archive.io.ObjectPlusFilesOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants, AutoCloseable

public class ObjectPlusFilesOutputStream extends ObjectOutputStream
Enhanced ObjectOutputStream which maintains (a stack of) auxiliary directories and offers convenience methods for serialized objects to save their related disk files alongside their serialized version.
Author:
gojomo
  • Field Details

    • auxiliaryDirectoryStack

      protected LinkedList<File> auxiliaryDirectoryStack
  • Constructor Details

  • Method Details

    • pushAuxiliaryDirectory

      public void pushAuxiliaryDirectory(String dir)
      Add another subdirectory for any file-capture needs during the current serialization.
      Parameters:
      dir -
    • popAuxiliaryDirectory

      public void popAuxiliaryDirectory()
      Remove the top subdirectory.
    • getAuxiliaryDirectory

      public File getAuxiliaryDirectory()
      Return the current auxiliary directory for storing files associated with serialized objects.
      Returns:
      Auxillary directory.
    • snapshotAppendOnlyFile

      public void snapshotAppendOnlyFile(File file) throws IOException
      Store a snapshot of an object's supporting file to the current auxiliary directory. Should only be used for files which are strictly appended-to, because it tries to use a "hard link" where possible (meaning that future edits to the original file's contents will also affect the snapshot). Remembers current file extent to allow a future restore to ignore subsequent appended data.
      Parameters:
      file -
      Throws:
      IOException