Code example for PushbackInputStream

0
    public void testLineNumberInputStream() throws IOException { 
        assertReadsFailWithNullPointerException(new LineNumberInputStream(null));
    } 
 
    public void testPushbackInputStream() throws IOException { 
        assertReadsFailWithIoException(new PushbackInputStream(null));
        assertReadsFailWithIoException(new PushbackInputStream(null, 1024));
    } 
 
    private void assertReadsFailWithIoException(InputStream in) throws IOException {
        try { 
            in.read();
            fail();
        } catch (IOException expected) {
        } 
 
        try { 
            in.available();
            fail();
        } catch (IOException expected) {
        }