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

Parsing a .txt file

s oc

Joined: Aug 02, 2006
Posts: 5
Hi there,

I am trying to parse a .txt file and don't know where to start. I am trying to get the file information from within the text file and output it to a SWT table. The file I'm trying to parse looks like the following with useless information before and after the file information. All I really need to do is somehow get each line and take its individual pieces of data and store them in an array or something so I can put them into my table.

Any help would be much appreciated,

Kind Regards,


File: penDriveImage3.001
Start: Wed Aug 02 19:49:44 2006
Length: 992 MB (1040187392 bytes)

Num Name (bs=512) Size File Offset Comment

0: 8426.jpg 5 KB 4314525 (null)
1: 13578.jpg 42 KB 6952364 (null)
2: 13663.jpg 27 KB 6995952 (null)
3: 13791.jpg 26 KB 7061467 (null)
4: 14825.jpg 46 KB 7590486 (null)
5: 16830.jpg 83 KB 8617069 (null)
6: 16999.jpg 36 KB 8703995 (null)
Fahd Shariff
Ranch Hand

Joined: Nov 22, 2002
Posts: 38
Use a BufferedFileReader to read the file line-by-line.

Use a StringTokenizer or String.split to break up each line into tokens which you can then put into your table.

Fahd Shariff<br />"Let the code do the talking"
I agree. Here's the link:
subject: Parsing a .txt file
It's not a secret anymore!