Why size1 is printing 65?, while size2 is showing 11 which is correct.
Is both methods are not same? I think read() is used to read the size of file while read(char[]) is used to read the file in char array and returns the size of file. Am I right? If I am right then why both are showing different values?
read() does *not* return the size of the file. It returns one char that is read (as a int with the unicode value) or -1, if there is nothing to read.
read(char[]) also does *not* return the size of the file. It returns the number of characters that it has read into the array. (and of course, store those values into the array)
See
the JavaDoc for more details.
Henry
[UPDATE NOTE: I like Barry's response better. Silly to keep coming here when it takes seconds to look it up]
[ September 20, 2006: Message edited by: Henry Wong ]