Re: datainput stream

From: Amey Samant (ameyas7_at_yahoo.com)
Date: 12/09/03


Date: 9 Dec 2003 10:16:44 -0800

hi

> 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 ???

> 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/DataIODemo.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

amey