Code example for PushbackReader

Methods: close, read

0
 
    /** 
     * java.io.PushbackReader#read(char[], int, int) 
     */ 
    public void test_read_$CII_Exception() throws IOException { 
        pbr = new PushbackReader(new StringReader(pbString), 10);
 
        char[] nullCharArray = null;
        char[] charArray = new char[10];
 
        try { 
            pbr.read(nullCharArray, 0, 1);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, 0, -1);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, -1, 0);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, charArray.length + 1, 0);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, charArray.length, 1);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, 1, charArray.length);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        try { 
            pbr.read(charArray, 0, charArray.length + 1);
            fail("should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected 
        } 
 
        pbr.close();
 
        try { 
            pbr.read(charArray, 0, 1);
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
    }