RandomAccessFile.readChar() |= '\n' does not work?

From: harald (please_noSpam_at_gmx.de)
Date: 12/27/04


Date: Mon, 27 Dec 2004 22:25:34 +0100

Hi,

I try to read a RandomAccessFile until the first newline and to count
all tabs.

But the following just won't do the job:
***********************
RandomAccessFile in = new RandomAccessFile(filename);
char c;
int num=0;
while ( (c=in.readChar()) != '\n' )
{
        if (c == '\t')
        {
                num++;
        }
}
***********************
According to the debugger the line with "num++" is never reached.
if I execute "print c" while jdb is in this loop, he tells me "c = ?"
Then an EOFException with message "null" is thrown.

Can someone tell me what goes wrong?

Wo liegt denn bitte mein Denkfehler?

Regards and thanks in advance,
Harald