aspose file tools*
The moose likes JNLP and Web Start and the fly likes Where to create files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "Where to create files?" Watch "Where to create files?" New topic
Author

Where to create files?

Frank Bush
Greenhorn

Joined: Apr 27, 2004
Posts: 8
My application deployed through Web Start creates a bunch of files that need to be accessed across invocations of the application (i.e. they are not deleted when the application shuts down).

I have a question related to where these files should be stored:

1) Is there any recommended location specific to Web Start?
2) If not, which system property should I look at, knowing that the application should be cross-platform? Or is there another way to find a suitable location?

Thanks a lot,
Frank
Ed Ewing
Greenhorn

Joined: Aug 30, 2005
Posts: 29
The quick-and-dirty answer is to create a subdirectory in the user's home directory and store your dirty secrets there.

For example:



You could take advantage of the separate Windows and Unix conventions of putting data in "Application Data" and in files beginning with ".". If the directory "Application Data" exists, you know you are on Windows. (But I doubt this works in non-English-speaking environments.)



A more transparent solution is to ask the user where to store files. The first time the program runs, it checks to see if the user has picked a location to store files. You can do this with the Preferences API.
If that directory has been defined, and exists, use it. Otherwise ask the user where to put your files and remember that location with the Preferences API.



Wherever you put the directory, I recommend that you let the user know where that directory is. For example, if you have a "Help->About" menu item, that could give information about where this directory is at, and might give the user a chance to move this directory and/or clear the contents.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where to create files?