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

  • SEARCH
  • Home
  • 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 8612883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:44:11+00:00 2026-06-12T04:44:11+00:00

I am trying to get 2D array data from a Java properties file and

  • 0

I am trying to get 2D array data from a Java properties file and store these data into a HashMap object.The thing that makes me puzzled is that Eclipse only retrieves only some of the data from the 2D array.

Here are the codes:

Properties config = new Properties();
config.load(new FileInputStream("categories.properties"));
String[][] categories = fetchArrayFromPropFile("content", config);
HashMap<String,Integer> hashmap = new HashMap<String,Integer>();
for (String[] mapping : categories)
{
  hashmap.put(mapping[0], 0);
}

private static String[][] fetchArrayFromPropFile(String propertyName, Properties propFile) {
  String[] a = propFile.getProperty(propertyName).split(";");
  String[][] array = new String[a.length][a.length];
  for(int i = 0;i < a.length;i++) {
    array[i] = a[i].split(",");
  }
  return array;
}

In categories.properties file:

content=Advertising,0;Agriculture,0;Art,0;Automotive,0;Aviation,0;Banking,0;Beverages,0;Biotechnology,0;Business,0;Crime,0;Disasters,0;Economics,0;Education,0;Elections,0;Fashion,0;Food,0;Hardware,0;Health,0;Hotels,0;Intellectual Property,0;Investing,0;Labor,0;
Law,0;Marriage,0;Mobile Devices,0;Politics,0;Real Estate,0;Renewable Energy,0;Robotics,0;Science,0;Social Media,0;Software and Internet,0;Space,0;Sports,0;Technology,0;Traditional Energy,0;Travel,0;Video Games,0;War,0;Weather,0;Entertainment,0;No Topic,0; Business_Finance,0;Disaster_Accident,0;Entertainment_Culture,0;Environment,0;Health_Medical_Pharma,0;Hospitality_Recreation,0;Human  Interest,0;Law_Crime,0;Religion_Belief,0;Technology_Internet,0;War_Conflict,0;Other,0;
  • 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-06-12T04:44:13+00:00Added an answer on June 12, 2026 at 4:44 am

    It is because your property file format is

    content=XXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    

    You see, it is split into two lines for one property. So when reading your content property, it reads only the first line and all data are not contained.

    If so, please concatenated your property file into one line manually like this.

    content=Advertising,0;Agriculture,0;Art,0;Automotive,0;Aviation,0;Banking,0;Beverages,0;Biotechnology,0;Business,0;Crime,0;Disasters,0;Economics,0;Education,0;Elections,0;Fashion,0;Food,0;Hardware,0;Health,0;Hotels,0;Intellectual Property,0;Investing,0;Labor,0;Law,0;Marriage,0;Mobile Devices,0;Politics,0;Real Estate,0;Renewable Energy,0;Robotics,0;Science,0;Social Media,0;Software and Internet,0;Space,0;Sports,0;Technology,0;Traditional Energy,0;Travel,0;Video Games,0;War,0;Weather,0;Entertainment,0;No Topic,0; Business_Finance,0;Disaster_Accident,0;Entertainment_Culture,0;Environment,0;Health_Medical_Pharma,0;Hospitality_Recreation,0;Human  Interest,0;Law_Crime,0;Religion_Belief,0;Technology_Internet,0;War_Conflict,0;Other,0;
    

    If so, your code works fine and all data are read.

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

Sidebar

Related Questions

I'm trying to get one object from this array and print all of its
I am trying to get column data from sqlLite DB and put that data
I am trying to get data from the db in the response object and
I'm trying to get some data from my database, and then pass it into
I'm trying to get the pixel data from a WPF BitmapSource object. As I
I'm trying to get the values from a pointer to a float array, but
I'm trying to get from an Android Uri to a byte array. I have
I'm trying to get a specific value from a mysql_fletch_assoc array. I explain. Here
From a text file I am trying to get the the 3rd set of
I'm was trying a tutorial to get data to android from a MySQL database

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.