Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing a .txt file

 
s oc
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Shinny

--START OF TEXT FILE--
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)
...RANDOM DATA HERE...
--END OF TEXT FILE--
 
Fahd Shariff
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic