Re: java.io.InputStream - read Strings separated by whitespaces
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/02/03
- Next message: Anthony Borla: "Re: toolkit beep - MS error perhaps"
- Previous message: Tor Iver Wilhelmsen: "Re: Instantiating a class read in from user input"
- In reply to: Angus Parvis: "java.io.InputStream - read Strings separated by whitespaces"
- Next in thread: Angus Parvis: "Re: java.io.InputStream - read Strings separated by whitespaces"
- Reply: Angus Parvis: "Re: java.io.InputStream - read Strings separated by whitespaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Anthony Borla: "Re: toolkit beep - MS error perhaps"
- Previous message: Tor Iver Wilhelmsen: "Re: Instantiating a class read in from user input"
- In reply to: Angus Parvis: "java.io.InputStream - read Strings separated by whitespaces"
- Next in thread: Angus Parvis: "Re: java.io.InputStream - read Strings separated by whitespaces"
- Reply: Angus Parvis: "Re: java.io.InputStream - read Strings separated by whitespaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|