Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:04:58+00:00 2026-05-24T06:04:58+00:00

I just recently learned about the Properties class in java, and I’m trying to

  • 0

I just recently learned about the Properties class in java, and I’m trying to translate my old configuration file to be compatible with the Properties class. I want to know what would be the best way to setup a properties file for something like this:

Object type1
name obj1
age age1

Object type2
name obj2
age age2

I used spaces because I was using a Scanner to parse the file. I would create a List of Objects that stored the different objects and each Object had certain parameters with them, which I would get from the config file. So as I read along the file I would get the properties and create the object and store into my List.

I don’t want to use XML to create my properties file. I want something simple for a user to create and something that I could read easily in Java.

Any suggestions?

EDIT:
I want to try to get something with no need of numbering. For example in XML you can do something like this:

<table>
   <fields>
      <field>
         <type>type1</type>
      </field>
      <field>
         <type>type2</type>
      <field>
   </fields>
</table>

Obviously it would be easier to make a XML file like this, but I want to implement in a non-XML way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:04:59+00:00Added an answer on May 24, 2026 at 6:04 am

    The property keys ought to be unique. I’d suggest to use a numerical infix.

    field1.type = type1
    field1.name = obj1
    field1.age = age1
    
    field2.type = type2
    field2.name = obj2
    field2.age = age2
    

    Then you can gather them in an incremental loop as follows:

    Properties properties = new Properties();
    properties.load(input);
    List<Field> fields = new ArrayList<Field>();
    
    for (int i = 1; i < Integer.MAX_VALUE; i++) {
        String type = properties.getProperty("field" + i + ".type");
        if (type == null) break;
        String name = properties.getProperty("field" + i + ".name");
        String age = properties.getProperty("field" + i + ".age");
        fields.add(new Field(type, name, age));
    }        
    

    Unrelated to the concrete problem, I am confident that XML is way much easier to maintain and parse, for example with JAXB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just recently got my first mac. I do lots of programming on windows
I just recently installed the MVC beta. However, I assumed because the versioning numbers
I just recently noticed Dictionary.TryGetValue(TKey key, out TValue value) and was curious as to
I just recently installed Winamp Song Requester wich is a Winamp web song requester
I just recently changed out all my hard drives and in the process of
I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as
I've just recently upgraded to SQL Server 2008 from 2005 and when I attempt
I've read the whole Dragon Book recently (just for fun, I'm not really planning
I've recently decided that I just have to finally learn C/C++, and there is
I've recently began using dTrace and have noticed just how awesome it is. Its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.