Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Where to create files?

Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic