Re: java.io.InputStream - read Strings separated by whitespaces

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/02/03


Date: Sun, 02 Nov 2003 21:49:01 GMT

Angus,

"Angus Parvis" <angusparvis@spamyourself.gmx.at> wrote in message
news:W6epb.129587$vL1.1617963@news.chello.at...
>
> I want to read Strings from the java.io.InputStream
> System.in. Like java.io.BufferedReader.readLn() reads
> from the Stream line-by-line i want to ready word-by-word,
> separated by whitespaces.
>
> I already got the advice to use a java.io.StreamTokenizer.
> But i'm new to Java and, though trying to apply it to my
> problem i couldn't solve the problem. I have to write the
> program for my studies an have to finish till tuesday. So
> please forgive my stupidity and *please* help
> out with some code. Thank you very much.
>

Ah, but providing code would be doing *your* homework, and thus defeat the
primary purpose of that task being assigned to you :) !

Since you already know how to read in line-by-line using the 'readLine'
method [as your post implies], you can build on that: use the 'String'
class' 'split' method to break each line into words. A very simple approach
that may help solve your immediate problem. If you then find you have time,
you can then perhaps work on improving the solution using 'StreamTokenizer'
etc.

It goes without saying that if you encounter coding, or compilation
difficulties, then again post here for help, not forgetting to include your
problem code in the message.

I hope this helps [and I truly believe it is better than just posting code].

Anthony Borla



Relevant Pages

  • New guitar problems advice
    ... Hopefully some can give me some advice. ... he doesn't have tweezers and his fingers are too big. ... Should I loosen all the strings and pull out the entire bridge then return ... I plucked again and it still made the buzz. ...
    (alt.guitar.beginner)
  • Re: New guitar problems advice
    ... Hopefully some can give me some advice. ... > strings to do this. ... Your guitar needs the equivalent of a car "tuneup". ...
    (alt.guitar.beginner)
  • Re: Nylon string advice
    ... as long as I can keep my fingers ... put extra-hard tension strings on it, ... advice would also be welcome. ... I use D'addario EJ46C strings. ...
    (rec.music.makers.guitar.acoustic)
  • Re: Keeping my Les Paul in tune
    ... I fitted Grover Rotomatics which were an improvement over the Kluson tuning heads. ... However, the guitar still won't hold tune well, especially on the G string with a big bend. ... I'm running 46-10 strings. ... Anyone have any advice for me? ...
    (alt.guitar)
  • Re: RegEx: How to ignore the number of whitespaces?
    ... I want to match strings while ignoring the number of whitespaces. ...
    (microsoft.public.dotnet.framework)

Loading