Code example for CharBuffer

Methods: append

        // Regression test for Harmony-4774 
        class CountReadable implements Readable {
            int counter = 0;
            public int read(CharBuffer charBuffer) throws IOException {
                return 6; 
        CountReadable cr = new CountReadable();
        s = new Scanner(cr);
        result = s.nextLine();
        // We expect read() to be called only once, otherwise we see the problem 
        // when reading from described in Harmony-4774 
        assertEquals(1, cr.counter);
        assertEquals("hello", result);        
     * @tests java.util.Scanner#hasNextLine() 
Experience pair programming with AI  Get Codota for Java