commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "B. K. Oxley (binkley)" <bink...@alumni.rice.edu>
Subject [vfs] temporary files
Date Wed, 02 Feb 2005 15:20:55 GMT
What's the right way to make a temporary file with VFS?  I need some for 
unit tests.  For the nonce I did this:

FileObject createTemporary() {
     // Using JDK UUID generator -- is this JDK1.3-compiant?
     final FileObject tmp = VFS.getManager().resolveFile(
             "tmp:/" + UUID.randomUUID());

     tmp.createFile();

     return tmp;
}

But this has several drawbacks, among them:
   * No automatic cleanup on exit as with File.deleteOnExit()
   * Depends on TempFS being configured
   * Relies on the static VFS.getManager() call
   * Smells hacky


Cheers,
--binkley

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message