Code example for LineNumberReader

Methods: getLineNumberread

0
 
    /** 
     * @tests java.io.LineNumberReader#read(char[], int, int) 
     */ 
    public void test_read$CII() throws IOException { 
        lnr = new LineNumberReader(new StringReader(text));
        char[] c = new char[100];
        lnr.read(c, 0, 4);
        assertTrue("Read returned incorrect characters", "0\n1\n"
                .equals(new String(c, 0, 4)));
        assertEquals("Read failed to inc lineNumber", 2, lnr.getLineNumber());
    } 
 
    /** 
     * @tests java.io.LineNumberReader#readLine() 
     */ 
    public void test_readLine() throws IOException { 
        lnr = new LineNumberReader(new StringReader(text));
        assertEquals("Returned incorrect line number", 0, lnr.getLineNumber());
        String line = null;
        lnr.readLine();