Extracting fields from file using StringTokenizer.

R

ruds

Hello,
How do we find the delimiters in the text file?
If i want to extract some specific fields from a text file, i wouold be
using StringTokenizer.
But how would i know which delimiters are used in the file?

Plz let me know of it.
 
T

timoi

You cannot know the delimiters before you have seen the file - seen
with your own eyes. Your computer won't be smart enough to recognize
delimiters.

But maybe there are just a few possibilities for the delimiters (like
',' or ';') and you could try if the field values for one of are
reasonable.

Or the fields have a fixed format (like numbers or quoted Strings).
Then you could use a regular expression to extract the field values
directly. I would propose this method.

You might as well read the first field's value. By knowing it's format,
it could be possible to identify the next character as the delimiter.
 
R

ruds

I wnat to read the file and perform some operations on some of the
fields in the file.
The output file has to be in the same format as the i/p file. How do i
do that? as the i/p file has multiple blank spaces in between the
fields.
 
R

Randolf Richardson

I wnat to read the file and perform some operations on some of the
fields in the file.
The output file has to be in the same format as the i/p file. How do i
do that? as the i/p file has multiple blank spaces in between the
fields.

Maybe com.internationalnetwork.util.StringParser has two methods which
may be of interest to you -- atomize() and splitPairs():

International Network - Java classes
http://www.internationalnetwork.com/java/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top