Package org.jboss.vfs

Class TempDir

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

    public final class TempDir
    extends java.lang.Object
    implements java.io.Closeable
    A temporary directory which exists until it is closed, at which time its contents will be removed.
    Author:
    David M. Lloyd
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close this directory.
      java.io.File createFile​(java.lang.String relativePath, java.io.InputStream sourceData)
      Create a file within this temporary directory, prepopulating the file from the given input stream.
      protected void finalize()  
      java.io.File getFile​(java.lang.String relativePath)
      Get the File for a relative path.
      java.io.File getRoot()
      Get the File that represents the root of this temporary directory.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRoot

        public java.io.File getRoot()
                             throws java.io.IOException
        Get the File that represents the root of this temporary directory. The returned file is only valid as long as the tempdir exists.
        Returns:
        the root file
        Throws:
        java.io.IOException - if the directory was closed at the time of this invocation
      • getFile

        public java.io.File getFile​(java.lang.String relativePath)
                             throws java.io.IOException
        Get the File for a relative path. The returned file is only valid as long as the tempdir exists.
        Parameters:
        relativePath - the relative path
        Returns:
        the corresponding file
        Throws:
        java.io.IOException - if the directory was closed at the time of this invocation
      • createFile

        public java.io.File createFile​(java.lang.String relativePath,
                                       java.io.InputStream sourceData)
                                throws java.io.IOException
        Create a file within this temporary directory, prepopulating the file from the given input stream.
        Parameters:
        relativePath - the relative path name
        sourceData - the source input stream to use
        Returns:
        the file
        Throws:
        java.io.IOException - if the directory was closed at the time of this invocation or an error occurs
      • close

        public void close()
                   throws java.io.IOException
        Close this directory. The contents of the directory will be removed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if an I/O error occurs
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable