Class FileBackedOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    @Beta
    @Deprecated(since="2022-12-01")
    public final class FileBackedOutputStream
    extends java.io.OutputStream
    Deprecated.
    The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
    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
    • Constructor Summary

      Constructors 
      Constructor Description
      FileBackedOutputStream​(int fileThreshold)
      Deprecated.
      Creates a new instance that uses the given file threshold, and does not reset the data when the ByteSource returned by asByteSource() is finalized.
      FileBackedOutputStream​(int fileThreshold, boolean resetOnFinalize)
      Deprecated.
      Creates a new instance that uses the given file threshold, and optionally resets the data when the ByteSource returned by asByteSource() is finalized.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      ByteSource asByteSource()
      Deprecated.
      Returns a readable ByteSource view of the data that has been written to this stream.
      void close()
      Deprecated.
       
      void flush()
      Deprecated.
       
      InputSupplier<java.io.InputStream> getSupplier()
      Deprecated.
      Use asByteSource() instead.
      void reset()
      Deprecated.
      Calls close() if not already closed, and then resets this object back to its initial state, for reuse.
      void write​(byte[] b)
      Deprecated.
       
      void write​(byte[] b, int off, int len)
      Deprecated.
       
      void write​(int b)
      Deprecated.
       
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileBackedOutputStream

        public FileBackedOutputStream​(int fileThreshold)
        Deprecated.
        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
      • FileBackedOutputStream

        public FileBackedOutputStream​(int fileThreshold,
                                      boolean resetOnFinalize)
        Deprecated.
        Creates a new instance that uses the given file threshold, and optionally resets 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
        resetOnFinalize - if true, the reset() method will be called when the ByteSource returned by asByteSource() is finalized
    • Method Detail

      • getSupplier

        @Deprecated
        public InputSupplier<java.io.InputStream> getSupplier()
        Deprecated.
        Use asByteSource() instead. This method is scheduled to be removed in Guava 16.0.
        Returns a supplier that may be used to retrieve the data buffered by this stream. This method returns the same object as asByteSource().
      • asByteSource

        public ByteSource asByteSource()
        Deprecated.
        Returns a readable ByteSource view of the data that has been written to this stream.
        Since:
        15.0
      • reset

        public void reset()
                   throws java.io.IOException
        Deprecated.
        Calls close() if not already closed, and then resets this object back to its initial state, for reuse. If data was buffered to a file, it will be deleted.
        Throws:
        java.io.IOException - if an I/O error occurred while deleting the file buffer
      • write

        public void write​(int b)
                   throws java.io.IOException
        Deprecated.
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Deprecated.
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Deprecated.
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Deprecated.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Deprecated.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException