The way I woul do it is:

BufferedReader in = new BufferedReader(new FileReader("foo"));

then you can do something like:

String s = in.readLine();

Then you can use StringTokenizer on the new string.  StringTokenizer is a
little simpler to use than StreamTokenizer.  If all you are doing is
breaking up a string, I would use StringTokenizer.

--Alex McCarrier
--Momentum Software, Inc.

On Tue, 4 May 1999, Jeff Galyan wrote:

> Use a StreamTokenizer to break the input stream into tokens, using
> whitespace as the quote character.
> 
> Daniel Ignat wrote:
> > 
> > 
> > now .. how can I read from file <message.test>
> > first line is:
> > 
> > May  4 15:51:04 dexter pppd[304]: local  IP address *.*.*.*
> > 
> > - in my scenario I need to read first line and:
> > read from second <space> May 4 and format text 'May 4'
> > read from next <space> 15:51:04 and rezult '15:51:04'
> > read from next <space> dexter .....
> > read from next <space> pppd[304]: ...
> > read from end off line and '..... rest of line'
> > 
> > go to next line ...
> > ...
> > 
> > Q: for this class I need to use FileReader - for read-in
> >    and FileWriter - for write-in ?
> > 
> 
> 
> -- 
> Jeff Galyan
> http://www.anamorphic.com
> http://www.sun.com
> jeffrey dot galyan at sun dot com
> talisman at anamorphic dot com
> Sun Certified Java(TM) Programmer
> ======================================================================
> Linus Torvalds on Microsoft and software development:
> "... if it's a hobby for me and a job for you, why are you doing such a
> shoddy job of it?"
> 
> The views expressed herein do not necessarily reflect those of my
> employer.
> 
> Sun Microsystems, Inc., has no connection to my involvement with the
> Mozilla Organization.
> 
> 
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to