1

I am working on a project and I need to save user configuration. The configuration is a set of Jchechboxes I need to store their state (true, false). Which do you think is the better way of saving it, in a file and if yes in what (ini, cfg, txt), or it is better to serialize the object with the states?? Or if there is another way, please tell me :)

Cheers

4 Answers 4

1

It depends if you need to access the variables many times, and when: at the start of the application or during runtime?

If this configuration is user-related maybe you want to keep separate configuration for each user serialized on a Database so you can load them dynamically when a user loads the form that displays the checkboxes.

If there's just one possible configuration for one user (or such) maybe you should just put everything in a text file (the extension doesn't matter: ini,cfg,txt,lol anything you want) just simplify your life by using standard Java configuration access using the Properties class: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html

Sign up to request clarification or add additional context in comments.

1 Comment

the you better go with a single properties file
1

How about a Properties file?

Comments

1

If you decided to store the properties as a serialized object then you will make changing the implementation of the gui much harder and thus less portable. If you save them in a text file then you are free to change the GUI implementation without any disruption to the user, whilst allowing the user to keep their saved properties.

As such, I would always recommend storing preferences in a properties type file. The Properties API, and related commons classes are pretty simple to use.

Comments

1

The best method is to use java.util.prefs to store user preferences

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.