Class FileBackedOutputStream

java.lang.Object
java.io.OutputStream
net.bluemind.common.io.FileBackedOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public final class FileBackedOutputStream extends OutputStream
An OutputStream that starts buffering to a byte array, but switches to file buffering once the data reaches a configurable size.

This class is thread-safe.

Since:
1.0
Author:
Chris Nokleberg
  • Constructor Details

    • FileBackedOutputStream

      public FileBackedOutputStream(int fileThreshold, String filenamePrefix)
      Creates a new instance that uses the given file threshold, and does not reset the data when the ByteSource returned by asByteSource() is finalized.
      Parameters:
      fileThreshold - the number of bytes before the stream should switch to buffering to a file
      filenamePrefix - name hint for the optional temporary file
    • FileBackedOutputStream

      public FileBackedOutputStream(int fileThreshold, int sizeHint, String filenamePrefix)
      Creates a new instance that uses the given file threshold, and does not reset the data when the ByteSource returned by asByteSource() is finalized.
      Parameters:
      fileThreshold - the number of bytes before the stream should switch to buffering to a file. Not smaller than core.io.write-buffer
      sizeHint - if size store is known in advance
      filenamePrefix - name hint for the optional temporary file
  • Method Details