Class TemporaryBuffer.LocalFile

java.lang.Object
java.io.OutputStream
org.eclipse.jgit.util.TemporaryBuffer
org.eclipse.jgit.util.TemporaryBuffer.LocalFile
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Enclosing class:
TemporaryBuffer

public static class TemporaryBuffer.LocalFile extends TemporaryBuffer
A fully buffered output stream using local disk storage for large data.

Initially this output stream buffers to memory and is therefore similar to ByteArrayOutputStream, but it shifts to using an on disk temporary file if the output gets too large.

The content of this buffered stream may be sent to another OutputStream only after this stream has been properly closed by TemporaryBuffer.close().

  • Field Details

    • directory

      private final File directory
      Directory to store the temporary file under.
    • onDiskFile

      private File onDiskFile
      Location of our temporary file if we are on disk; otherwise null.

      If we exceeded the TemporaryBuffer.inCoreLimit we nulled out TemporaryBuffer.blocks and created this file instead. All output goes here through overflow().

  • Constructor Details

    • LocalFile

      public LocalFile(File directory)
      Create a new temporary buffer, limiting memory usage.
      Parameters:
      directory - if the buffer has to spill over into a temporary file, the directory where the file should be saved. If null the system default temporary directory (for example /tmp) will be used instead.
    • LocalFile

      public LocalFile(File directory, int inCoreLimit)
      Create a new temporary buffer, limiting memory usage.
      Parameters:
      directory - if the buffer has to spill over into a temporary file, the directory where the file should be saved. If null the system default temporary directory (for example /tmp) will be used instead.
      inCoreLimit - maximum number of bytes to store in memory. Storage beyond this limit will use the local file.
  • Method Details