Hi all so far ive used following code for reading integers from std i/p DataInputStream ds= new DataInputStream(System.in); int i= Integer.parseInt(ds.readLine()); can i not use 'readInt()' of DataInputStream to read integers from std i/p. if yes how, if no why int i= ds.readInt() gives a weird value... any explainations
hi dey! when we accept input from keyboard it will be always string only. we cannot accept integer values directly.when u read the input (even if the input is integers), that will be treated as string.so when u said "ds.readInt()" , it is returning the unicode value of the integers u are accepting from keyboard. i hope i could answer your question. bye
I forgot to tell you, DataInputStream is really meant to handle data generated by DataOutPutStream. That's why you can't directly use readInt().
Joined: Sep 25, 2000
hi guys thanx for helping, point taken now i have few more related problems say i create a form, n i wanna store the data in a binary file using DataOutputStream. when i try reading info from the file (using DataInputStream) there are no problems if the data is numeric, but while reading text fields i get a warning coz readLine is deprecated ( as pointed out by bkkumar ), readBytes would require me to provide the number of bytes to be read, i can't use Reader classes out there coz the result would be a text file which i don't want is there any way out...