Class TemporaryAssetFolder

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

    public class TemporaryAssetFolder
    extends java.lang.Object
    implements java.io.Closeable
    A temporary asset folder where an arbitrary number of files can be added to and should guarantee complete cleanup on close. Example usage:
    
     try (TemporaryAssetFolder tmp = new TemporaryAssetFolder(base)) {
         // do stuff
     }
     // is all deleted.
     
    This will create a temp folder into the base directory for each run, where any number of files or sub-folders can be added. All of it will be removed immediately on close.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.io.File getFile()  
      java.nio.file.Path getPath()  
      • Methods inherited from class java.lang.Object

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

      • TemporaryAssetFolder

        public TemporaryAssetFolder​(java.io.File baseTempDirectory)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • TemporaryAssetFolder

        public TemporaryAssetFolder​(java.nio.file.Path baseTempDirectory)
                             throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getPath

        public java.nio.file.Path getPath()
      • getFile

        public java.io.File getFile()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException