DataOutputStream writes in binary, not text. Your program wrote the 16-bit binary value for 12 to the file, not the characters "1" and "2". You will not be able to look at a file written by it, using an ordinary text editor.
In your particular editor, you see the "little square", because that is how your editor shows a value that doesn't look like text.
You need to read up more on the various ways of writing data to streams and writers.
BTW it's best not to say that a particular API method "X() doesn't work". This suggests that you think you have found a bug in the Sun Java implementation. While not impossible, it is unlikely that you have. Suggesting it can be read as arrogance, though I'm sure you didn't mean it that way. Better to say "I am having trouble using X()"
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Sorry about the title, was late at night. When I use the writeChar() method it writes the character symbol as is to the file, and when I use readChar to read it back it also reads back the same characters.
Is there a way I can do that using the datainput/output stream for shorts, and integers. I know it sounds stupid, but I have to use the datastreams to do this. Thanks in advance
Catch Ernie! Catch the egg! And catch this tiny ad too: