So, I’m doing a project and now I have a question, so I would like your help 🙂
First, I already know how to write and read a .txt file, but I want something more than just x.hasNext().
I want to know how could write, read and modify a .txt file like .ini does. What? Simple (I think):
First, write a file like this:
[client1]
name=Bill Gates
nick=Uncle Bill
number=123456789
[client2]
name=Steve Jobs
nick=Stevie
number=987654321
And so many other parameters, just like above, but when I’m wanting to read a specific one (like name or nick of a certain “client”) I can do it with easy (Ok, I know it will not be easy, but I think you understood :D)
So, if you already know what I want to learn, please, teach me 🙂 If you don’t, please explain me what you didn’t understood 😀
Thanks in advance for every helping
The format you describe is for a Windows .ini file, back from Windows 3.x days:
Perhaps the closest thing to a “standard format” in Java is a “properties” file; typically in the format “name=value”:
If you were to write your own program and invent your own initialization file format, would not use an .ini file. Instead, I would recommend:
1) simple properties file (if possible)
2) an XML file (if you need multi-level, structured data)
However, if you want to read and write existing .ini files for an existing application, I would either:
1) write my own .ini parser (it isn’t difficult)
2) Download and run a library likke ini4j:
‘Hope that helps!