Re: datainput stream
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 12/09/03
- Next message: G3nius: "Proxy with Sun Java"
- Previous message: Jake: "optional.jar appears correct but junit and jspc doesn't work"
- In reply to: Amey Samant: "Re: datainput stream"
- Next in thread: Amey Samant: "Re: datainput stream"
- Reply: Amey Samant: "Re: datainput stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 09 Dec 2003 21:20:05 GMT
"Amey Samant" <ameyas7@yahoo.com> wrote in message
news:669e50b8.0312091016.1d726b19@posting.google.com...
>
> > It is designed to read in a value which is encoded as a
> >binary integer. The values from 'System.in' are *not*
> > so-encoded, therefore you get what appear to be
> > random or nonsense values.
>
>
> > The data from 'System.in' is, instead, encoded as
> > characters. When performing interactive console
> > I/O you will find that input is merely a series of
> > characters terminated by the newline character.
>
> i did not follow this, i mean System.in is an object of
> InputStream which is ByteStream & not a character
> stream so what is your point ???
>
My point, and the only reason for my bothering to respond to your query, was
to help you solve your problem, and, as a by-product, help teach you a
little about streams.
Try the code I posted - it illustrates a known, efficient, and reliable
method for interactively extracting 'int' values from a character input
stream.
> > It's actually meant to decode data that was originally
> > written using a 'DataOutputStream' ! Although the results
> > look strange, it is behaving *exactly* as it should. The
> > problem, as mentioned earlier, is that the wrong type of
> > data has been supplied to 'readInt'.
>
>
http://java.sun.com/docs/books/tutorial/essential/io/example-1dot1/DataIODem
o.java
>
> this is an example from SUN s tutorial on I/O
> believe me when i downloaded this, compiled & run it DIDNT
> work the input read with readInt() appears like "?????"
> try it & let me know if you get the same thing
> i use WinXP , j2se 1.4.1_02
>
No, I don't have the time to conduct such experiments. I believe I've been
more than helpful:
* Posted useful code which you can modify and use
* Briefly described why you were experiencing such
difficulties
I suggest that you re-read the tutorials noting the reasons why both stream
and reader [character stream] classes exist.
Anthony Borla
- Next message: G3nius: "Proxy with Sun Java"
- Previous message: Jake: "optional.jar appears correct but junit and jspc doesn't work"
- In reply to: Amey Samant: "Re: datainput stream"
- Next in thread: Amey Samant: "Re: datainput stream"
- Reply: Amey Samant: "Re: datainput stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|