Class TempSharedFileInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
jakarta.mail.util.SharedFileInputStream
com.helger.as2lib.util.http.TempSharedFileInputStream
All Implemented Interfaces:
jakarta.mail.internet.SharedInputStream, Closeable, AutoCloseable

public class TempSharedFileInputStream extends jakarta.mail.util.SharedFileInputStream
Stores the content of the input InputStream in a temporary file, and opens SharedFileInputStream on that file. When the stream is closed, the file will be deleted, and the input stream will be closed.
  • Method Details

    • close

      public void close() throws IOException
      close - Do nothing, to prevent early close, as the cryptographic processing stages closes their input stream
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class jakarta.mail.util.SharedFileInputStream
      Throws:
      IOException
    • finalize

      protected void finalize() throws Throwable
      finalize - closes also the input stream, and deletes the backing file
      Overrides:
      finalize in class jakarta.mail.util.SharedFileInputStream
      Throws:
      Throwable
    • closeAll

      @Deprecated(forRemoval=true, since="4.10.2") public void closeAll() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since 4.10.2. Use closeAndDelete() instead
      closeAll - closes the input stream, and deletes the backing file
      Throws:
      IOException - in case of error
    • closeAndDelete

      public void closeAndDelete() throws IOException
      closeAll - closes the input stream, and deletes the backing file
      Throws:
      IOException - in case of error
      Since:
      4.10.2
    • storeContentToTempFile

      @Nonnull protected static File storeContentToTempFile(@Nonnull @WillClose InputStream aIS, @Nonnull String sName) throws IOException
      Stores the content of the input InputStream in a temporary file (in the system temporary directory.
      Parameters:
      aIS - InputStream to read from
      sName - name to use in the temporary file to link it to the delivered message. May be null
      Returns:
      The created File
      Throws:
      IOException - in case of IO error
    • getTempSharedFileInputStream

      @Nonnull public static TempSharedFileInputStream getTempSharedFileInputStream(@Nonnull @WillClose InputStream aIS, @Nonnull String sName) throws IOException
      Stores the content of the input InputStream in a temporary file (in the system temporary directory, and opens SharedFileInputStream on that file.
      Parameters:
      aIS - InputStream to read from
      sName - name to use in the temporary file to link it to the delivered message. May be null
      Returns:
      TempSharedFileInputStream on the created temporary file.
      Throws:
      IOException - in case of IO error