Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How and where do you save user settings?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How and where do you save user settings?

    OK, sooner or later everyone needs to save some user input data, like username/password for some server.
    What are the techniques for saving the data?

    Let's say I want to write a program similar to filezilla ftp client. The user creates a new ftp connection and wants to save host/port/username/password so that next time he does not have to type it manually.

    How would I go about saving this data? A text file? a database entry somewhere? Do I have to specify the location (directory/file name) or does java automatically create some file for these?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,916
    Thanks
    55
    Thanked 2,352 Times in 2,323 Posts

    Default Re: How and where do you save user settings?

    Look at the Preferences class.
    Or if you'd prefer using a file, look at the Properites class

  3. #3
    Member
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    0
    Thanked 2 Times in 1 Post

    Default Re: How and where do you save user settings?

    Create a class that implements Serializable interface with the necessary field for your information (username, pasword, etc.), create an object of this class and save it on a file via ObjectOutputStream, check this link for the documention. ObjectOutputStream (Java 2 Platform SE v1.4.2)RL]

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    495
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: How and where do you save user settings?

    Quote Originally Posted by relixus View Post
    Create a class that implements Serializable interface with the necessary field for your information (username, pasword, etc.), create an object of this class and save it on a file via ObjectOutputStream, check this link for the documention. ObjectOutputStream (Java 2 Platform SE v1.4.2)RL]
    No, don't do that. Norm has already posted good and correct advice.

    db

Similar Threads

  1. Can't get it to save stuff with JFileChooser
    By javapenguin in forum What's Wrong With My Code?
    Replies: 35
    Last Post: August 11th, 2010, 05:13 AM
  2. Java JTextPane Save
    By ikurtz in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: April 28th, 2010, 02:02 AM
  3. get proxy settings from the default system browser
    By reguapo in forum Java Networking
    Replies: 0
    Last Post: January 15th, 2010, 08:43 AM
  4. Arraylist Save and Load
    By frankycool in forum Collections and Generics
    Replies: 1
    Last Post: November 14th, 2009, 06:48 AM
  5. Saving .jsp page as .pdf file while generating report for struts based web application
    By ravindra_kumar_tiwari in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: August 12th, 2008, 10:32 AM