This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing a .txt file" Watch "Parsing a .txt file" New topic
Author

Parsing a .txt file

s oc
Greenhorn

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,

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

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: http://aspose.com/file-tools
 
subject: Parsing a .txt file
 
Similar Threads
Parsing of String
parse a csv file (PLEASE HELP)
database(?) and stuff
How to convert a .doc file to .txt file
A question regarding saving jpgs into text files.