views:

130

answers:

1

In my jnlp app I need to know if a user property file exists, if it does, load it, my code looks like this :

File_Contents=File_Open_Service.openFileDialog(".",new String[]{".txt"});
String Text=readFromFile(File_Contents);

InputStreamReader in=new InputStreamReader(File_Contents.getInputStream());
Application_Props.load(in);

Users don't know the name of the property file, so even if I open a dialog box, they won't know which file to choose, so my question is : in jnlp can I do something like : if (new File("abc.txt").exists) Load_Property() ? If it doesn't exist, go on without popping up a dialog box, if it exists, don't need to open a dialog box either, just read it in, if necessary, ask the user if it's ok to read in a file named "abc.txt" as a property file. How to achieve this in jnlp ? Any sample code ?

PS : I'm not running it in "all-permissions" mode, because that requires a 3rd party cert. which cost a bit.

A: 

Alright, I've figured out how to achieve this : use the PersistenceService. I can save the user setting into something like a cookie in html with the help of JNLP's PersistenceService, and load it next time without the need to open a dialog box every time.

I can easily detect if it exists or not without asking users.

Frank