Code example for LineNumberReader

Methods: getLineNumber, mark, readLine, reset

0
 
    /** 
     * @tests java.io.LineNumberReader#reset() 
     */ 
    public void test_reset() throws IOException { 
        lnr = new LineNumberReader(new StringReader(text));
        assertEquals("Returned incorrect line number", 0, lnr.getLineNumber());
        String line = null;
        lnr.mark(100);
        lnr.readLine();
        lnr.reset();
        line = lnr.readLine();
 
        assertEquals("Failed to reset reader", "0", line);
    } 
 
    public void testReadLineSourceThrows() throws IOException { 
        lnr = new LineNumberReader(new Reader() {
            private StringReader delegate = new StringReader("hello\nworld");
            private int calls = 0;
            @Override public void close() throws IOException {}