File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Parsing a delimited text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parsing a delimited text file" Watch "Parsing a delimited text file" New topic

Parsing a delimited text file

Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91

Are there any good resources on the web where i can learn how to parse a delimited text file, and save the data in a map data structure.


I would appreciate any help,

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Your question isn't very specific.. which makes it abit harder to help you.

Try Google

Map datastructure:

/Svend Rost
Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
Sorry about that.

I have a text file:

Now i need to write a parser which will parse these name / value pairs, and populate a Map.

I appreciate your help.

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
For the parsing, use String.split() if you are developing with Java 1.4 or above. Otherwise, look at StringTokenizer.


Java API Documentation
The Java Tutorial
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
JDK 1.4 also offers regular expressions, and JDK 5 builds on regex with a nifty goodie called Scanner. So many choices! Layne's suggestions are the easiest by far, and a great place to start. Have fun, let us know what you wind up with.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Parsing a delimited text file
It's not a secret anymore!