Results 1 to 2 of 2
Thread: .ini files...
- 12-17-2009, 12:08 PM #1Member
- Join Date
- Nov 2009
- Rep Power
- 12-18-2009, 02:55 AM #2
well, a socket has an input stream.
an input stream can be read with a reader.
a reader supports reading line-oriented things.
an ini file has two types of lines, the [header] in the square bracket thing, and the key=value kind of thing.
in an ideal case one would create a grammar, such as using ANTLR or jflex that produces tokens from scanning the input text, kind of like a regular expression.
in a pinch, I guess you could read a line from the reader that is wrapping the input stream from the socket and do simple "if line starts with [ " then consider it to be the start of a section, else if it starts with ";" or "#" or is empty, then consider it a comment or white space and then ignore it. otherwise read the line, split it on the "=", the stuff on the left hand side is the key name, the stuff on the right hand side is the value. Then take, this key/value, and stuff it into the contents for the current 'section'.
Conceptually, the data storage for an in-memory view of the contents of an .ini file might look like.
Map<String, Map<String, String>> iniFileContents;
But, this kind of thing has already been figured out, back in 2004. See the posting on CodeProject site. CodeProject: An Enhanced INI File Class for Java. Free source code and programming help
- By itaipee in forum New To JavaReplies: 1Last Post: 02-24-2009, 12:38 PM
- By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM
- By erhart in forum Advanced JavaReplies: 8Last Post: 01-19-2008, 05:43 AM
- By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:14 AM
- By bbq in forum New To JavaReplies: 3Last Post: 07-20-2007, 03:56 AM