Results 1 to 1 of 1
- 03-04-2009, 11:08 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 37
- Rep Power
- 0
Use Scanner to parse text file, adding to HashMap
Ok,
I have a text file like this
------------------
Textfile.txt
comments like these should be skipped
{
<randomItemName>
values of item ;
values of item 2;
}
Comments
{
<randomItemName2>
values of item ;
values of item 2;
}
More comments
----------------------------
So basically I need to parse through the string and first of all skip over all the comments then add any thing in the { } into a hash map like this:
hasmapName.put("<randomitemName>", "values of item ; values of item2 ;");
and put all of them into the hashmap with the key being the randomitemName
I can do it with if statements and switch statements but I'm trying to figure out how to do it with a scanner (which I think would be cleaner code).
Thanks for any help
Similar Threads
-
Parse EDI File Using java
By vaskarbasak in forum Advanced JavaReplies: 6Last Post: 09-24-2008, 02:38 PM -
How to parse an xml file using java
By karthik84 in forum XMLReplies: 4Last Post: 09-12-2008, 09:38 AM -
Adding lines at start and end of the text file
By phani532 in forum New To JavaReplies: 5Last Post: 08-27-2008, 03:12 PM -
How to parse the CSV(Comma separation values)file and validate the file using java
By padmajap13 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 03:46 AM -
how to parse an xml file
By oregon in forum XMLReplies: 3Last Post: 08-01-2007, 04:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks