|
-
April 15th, 2019, 03:22 AM
#1
Reading .ini files
I'm in a process of translating some old code and I'm stuck on reading some specific ".ini" files, I use
Code:
java.util.Properties
like this:
Code:
Properties prop = new Properties();
prop.load(new FileInputStream("sample.ini"));
prop.forEach((key, value) -> System.out.println("Key : " + key + ", Value : " + value));
This is the "sample.ini":
[Sec1]
Key1.1=Val1.1
Key1.2=Val1.2
[Sec2]
Key2.1=Val2.1
But the section's end up being read as keys, this is what I get as an output:
Key : Key1.1, Value : Val1.1
Key : Key1.2, Value : Val1.2
Key : [Sec2], Value :
Key : Key2.1, Value : Val2.1
Key : [Sec1], Value :
If needed, I could work with this and handle the section names myself, but then the problem is that the data is not stored in the same order as it was in the input file.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|