posted 17 years ago
OK, first off - I hope this question is suitable for the Beginners section, and not the Intermediates ! - I certainly do not consider myself anything other than a Beginner ....... So, here goes nothing .....
Is there a difference in the return value / data type returned of System.in.read() and BufferedReader.read() ?
By this, I mean they both return an int - right ? An int being 16 bits ?
Heres the deal. I have written 2 methods within a console application. One reads from stdin into a StringBuffer object until eof; the other reads from a file into a StringBuffer object until eof.
I wont bore you with the entire code, but the 2 methods in question are:
The objective of the application is to take a stream from stdin, or read a file from disk, and produce a dump of each byte in decimal, hex, and the ascii. (A lot like debug or many other file dumpers do in fact - thats not the point, its a learning excercise for me !)
If I run the application, and pipe into it a binary file - and consequently use the readStdin() method - it 'seems' to work perfectly.
If I run the app and read the same file from disk, using the readFile() method, for the most part the output is the same, but occasionally there are differences.
If I do the same with standard text files, both methods return the same results. Its only on binary files that there seems to be a difference.
Any ideas ??
Cheers
Nathan