Class TemporaryFiles


  • public class TemporaryFiles
    extends java.lang.Object
    Provides means to manage temporary FileChannel content.
    Author:
    Daniel Sagenschneider
    • Constructor Summary

      Constructors 
      Constructor Description
      TemporaryFiles​(java.lang.String prefix)
      Instantiate and creates the temporary files area.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.channels.FileChannel createTempFile​(java.lang.String name, byte[] contents)
      Creates a FileChannel to a temporary file.
      java.nio.channels.FileChannel createTempFile​(java.lang.String name, byte[] contents, int offset, int length)
      Creates a FileChannel to a temporary file.
      java.nio.channels.FileChannel createTempFile​(java.lang.String name, java.io.InputStream contents)
      Creates a FileChannel to the temporary file.
      java.nio.channels.FileChannel createTempFile​(java.lang.String name, java.lang.String contents)
      Creates a FileChannel to the temporary file using the default HTTP entity Charset.
      java.nio.channels.FileChannel createTempFile​(java.lang.String name, java.lang.String contents, java.nio.charset.Charset charset)
      Creates a FileChannel to the temporary file.
      static TemporaryFiles getDefault()
      Obtains the default TemporaryFiles.
      • Methods inherited from class java.lang.Object

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

      • TemporaryFiles

        public TemporaryFiles​(java.lang.String prefix)
                       throws java.io.IOException
        Instantiate and creates the temporary files area.
        Parameters:
        prefix - Prefix for the temporary files area.
        Throws:
        java.io.IOException - If fails to setup temporary files.
    • Method Detail

      • createTempFile

        public java.nio.channels.FileChannel createTempFile​(java.lang.String name,
                                                            java.io.InputStream contents)
                                                     throws java.io.IOException
        Creates a FileChannel to the temporary file.
        Parameters:
        name - Name to aid identifying the temporary file on disk. May be null.
        contents - InputStream to contents for the temporary file.
        Returns:
        FileChannel to the temporary file.
        Throws:
        java.io.IOException - If fails to create temporary file.
      • createTempFile

        public java.nio.channels.FileChannel createTempFile​(java.lang.String name,
                                                            byte[] contents,
                                                            int offset,
                                                            int length)
                                                     throws java.io.IOException
        Creates a FileChannel to a temporary file.
        Parameters:
        name - Name to aid identifying the temporary file on disk. May be null.
        contents - Contents for the temporary file.
        offset - Offset into contents.
        length - Length from offset to write to file.
        Returns:
        FileChannel to the temporary file.
        Throws:
        java.io.IOException - If fails to create temporary file.
      • createTempFile

        public java.nio.channels.FileChannel createTempFile​(java.lang.String name,
                                                            byte[] contents)
                                                     throws java.io.IOException
        Creates a FileChannel to a temporary file.
        Parameters:
        name - Name to aid identifying the temporary file on disk. May be null.
        contents - Contents for the temporary file.
        Returns:
        FileChannel to the temporary file.
        Throws:
        java.io.IOException - If fails to create temporary file.
      • createTempFile

        public java.nio.channels.FileChannel createTempFile​(java.lang.String name,
                                                            java.lang.String contents,
                                                            java.nio.charset.Charset charset)
                                                     throws java.io.IOException
        Creates a FileChannel to the temporary file.
        Parameters:
        name - Name to aid identifying the temporary file on disk. May be null.
        contents - Contents for the temporary file.
        charset - Charset to write the contents. May be null to use default HTTP entity Charset.
        Returns:
        FileChannel to the temporary file.
        Throws:
        java.io.IOException - If fails to create temporary file.
      • createTempFile

        public java.nio.channels.FileChannel createTempFile​(java.lang.String name,
                                                            java.lang.String contents)
                                                     throws java.io.IOException
        Creates a FileChannel to the temporary file using the default HTTP entity Charset.
        Parameters:
        name - Name to aid identifying the temporary file on disk. May be null.
        contents - Contents for the temporary file.
        Returns:
        FileChannel to the temporary file.
        Throws:
        java.io.IOException - If fails to create temporary file.