Results 1 to 2 of 2
Thread: .ini files...
- 12-17-2009, 11:08 AM #1
Member
- Join Date
- Nov 2009
- Location
- Pretoria
- Posts
- 12
- Rep Power
- 0
- 12-18-2009, 01: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.
Where the outer map stores the 'section' name, and the inner map stores each key-value entry within the map.Java Code: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
Similar Threads
-
working with files (text files)
By itaipee in forum New To JavaReplies: 1Last Post: 02-24-2009, 11:38 AM -
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM -
Text and image files within jar files
By erhart in forum Advanced JavaReplies: 8Last Post: 01-19-2008, 04:43 AM -
how to convert mpeg files to .wav files
By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:14 AM -
convert xls files into pdf files
By bbq in forum New To JavaReplies: 3Last Post: 07-20-2007, 03:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks