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 6636861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:14:22+00:00 2026-05-25T23:14:22+00:00

I read an .ini File and put every property into an temporary array which

  • 0

I read an .ini File and put every property into an temporary array which i put at the end into a vector – until here it works fine.

But if I want to access every array in that vector, I get ALWAYS the same results, which is impossible. I tried it with different ways, different loops and everything different, but always the same results, here is my actuall code:

    tmp2 = new String[2];
    for(Enumeration e=allPropertys.elements(); e.hasMoreElements();) {
        tmp2 = (String[])e.nextElement();
        for(int i = 0; i < tmp2.length; i++)
        {
            System.out.println(tmp2[i]);
        }
    }

And here is the code where I put everything into the vector:

    try {
        tmp = new String[2];

        prop = new Properties();
        prop.load(new FileReader("konfig.ini"));

        Enumeration e = prop.propertyNames();
        while (e.hasMoreElements()) {

            String key = (String)e.nextElement();
            String value = prop.getProperty( key );
            tmp[0] = key + " " +  value;
            tmp[1] = value;

            System.out.println("Property: " + tmp[0] + " und Value: " + tmp[1]);
            allPropertys.add(tmp);
        }
    }
  • 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-25T23:14:22+00:00Added an answer on May 25, 2026 at 11:14 pm

    My guess is that when you populate your vector, you reuse the same string array for every property. This makes you vector contain 10 times (10 being the number of entries) the same array:

    String[] property = new String[2];
    for (every line in the file) {
        property[0] = ...;
        property[1] = ...;
        vector.add(property);
    }
    

    This should be replaced by

    for (every line in the file) {
        String[] property = new String[2];
        property[0] = ...;
        property[1] = ...;
        vector.add(property);
    }
    

    Also, note in your code snippet, you create a new String array to initialize your tmp2 variable, and then replace its value by the one in the vector. The initialization is unnecessary.

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

Sidebar

Related Questions

What AS3 class should I use to read a simple property/ini file into memory
using Fast CGI I can't get it to read the php.ini file. See my
I have an INI file that I want to read the line DeviceName=PHJ01444-MC35 from
Is there a way to read a module's configuration ini file? For example I
I am trying to read an ini file that has the following format: SETTING=VALUE
I need to read, write and create an INI file with Python3. FILE.INI default_path
I have a ini file which contains some sample values like: [Section1] Value1 =
I have ini file that I read in my program. The ini file need
Is there a way to read properties from an INI file with apache ant?
I have put a config ini file config.ini for reading and writing to from

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.