Hi Archie, On Mon, 21 Jun 1999, Archie Cobbs wrote: AC| Do you have a simple test case to demonstrate this bug? I have a slightly AC| different patch I'd like to try. In the Attachement. Should return something like 012 / 123 / 234 / ... I see what you mean, my patch was buggy as well: we've to refill the Buffer at position 'size', not 'pos': --- if (size < readAheadLimit) refillBuffer (size) --- ciao, -hen --- Henner Zeller [EMAIL PROTECTED] PGP pub key [77F75B39]: finger [EMAIL PROTECTED] If Microsoft is the answer, it must have been a VERY silly question.
/* * Test-case to check wether java.io.BufferedReader works. * H.Z. */ import java.io.BufferedReader; import java.io.StringReader; public class BufferedReaderBug { public static int READLEN = 3; public static void main (String argv[]) { /* * the source we read from. */ StringReader source = new StringReader ("0123456789ABC"); /* * limit Buffer size to 5 */ BufferedReader b = new BufferedReader (source, 5); char buf[] = new char [READLEN]; try { for (;;) { b.mark( READLEN ); int charsRead = 0; int len = 0; // read until required size read .. while (charsRead < READLEN && (len = b.read (buf, charsRead, READLEN-charsRead)) >= 0) charsRead += len; if (len < 0) break; // done. System.err.println ("read " + buf); b.reset(); b.read(); // next char } } catch (java.io.IOException e) { e.printStackTrace(); } } }