Re: BufferedInputStream is broken

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Mon Dec 14 1998 - 01:18:54 EST


>
> Godmar Back writes:
> > I'm not sure how to best fix this.
> > I think it would be easier for whoever wrote BufferInputStream.java
>
> I didn't write it, but if you write a simple test class that
> exhibits the behavior, I'll work on it.. (tit for tat :-)
> Then we'll put the test in the regression suite.
>

There you go:

import java.io.*;

public class Buffer
{
    public static void main(String av[]) throws Exception {
        BufferedInputStream b = new BufferedInputStream(
                new StringBufferInputStream("ABCDEF"));
        b.mark(3);
        b.read();
        b.read();
        b.read();
        b.reset();
        b.mark(-1);
        byte []bb = new byte[5];
        int r = b.read(bb, 0, 5);
        if (r == 5) {
            System.out.println("Success.");
        } else {
            System.out.println("Failure " + r);
        }
    }
}


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:14 EDT