• Post Reply Bookmark Topic Watch Topic
  • New Topic

temp files  RSS feed

 
Jacob Whitten
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i'm making a desktop program for encryption using Christian Schlichtherle's
TrueZip classes.
my encrypted archives are viewable in JTree. i have a menu for different function like opening the file in a program using


i have to copy the file from the archive first to a temp folder. it's very fast in Java but files don't always get deleted though so i wanted to find out if there is any way to open the file directly from the archive or to create a hidden file like on Windows. There is practically not much documents on TrueZip site

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moved.
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.File has four nice methods for this:
- createTempFile(String prefix, String suffix) (static) returns a unique file in the default system temporary directory, starting with prefix and ending with suffix.

- createTempFile(String prefix, String suffix, File directory) (static) creates a similar file but in the specified directory.

- delete() attempts to delete the file immediately, and returns whether it could

- deleteOnExit() attempts to delete the file once the JVM exits.


A combination of the first (or second) and fourth should help you along quite nicely.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!