Package java.io

Examples of java.io.Reader.skip()


        && in.read() == (char) 7);

    in = new BufferedReader(new Support_StringReader(new String(chars)), 12);
    in.skip(6);
    in.mark(8);
    in.skip(7);
    in.reset();
    assertTrue("Wrong chars 2", in.read() == (char) 6
        && in.read() == (char) 7);
   
        BufferedReader br = new BufferedReader(new StringReader("01234"), 2);
View Full Code Here


        assertEquals(9, reader.read(buf));
        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
        assertEquals(false, reader.ready());
        assertEquals(0, reader.skip(2));
        assertEquals(0, reader.skip(-1));
       
        assertEquals(true, reader.markSupported());
        reader = sb.asReader();
        assertEquals('s', reader.read());
View Full Code Here

        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
        assertEquals(false, reader.ready());
        assertEquals(0, reader.skip(2));
        assertEquals(0, reader.skip(-1));
       
        assertEquals(true, reader.markSupported());
        reader = sb.asReader();
        assertEquals('s', reader.read());
        reader.mark(-1);
View Full Code Here

        reader.reset();
        assertEquals(1, reader.read(array, 1, 1));
        assertEquals('o', array[0]);
        assertEquals('o', array[1]);
        assertEquals('e', array[2]);
        assertEquals(2, reader.skip(2));
        assertEquals(' ', reader.read());
       
        assertEquals(true, reader.ready());
        reader.close();
        assertEquals(true, reader.ready());
View Full Code Here

        assertEquals(0, reader.read(array, 0, 0));
        assertEquals(0, array[0]);
        assertEquals(0, array[1]);
        assertEquals(0, array[2]);
       
        reader.skip(9);
        assertEquals(-1, reader.read(array, 0, 1));
       
        reader.reset();
        array = new char[30];
        assertEquals(9, reader.read(array, 0, 30));
View Full Code Here

     */
   public void testSkip() throws Exception {
        Reader reader = new TestNullReader(10, true, false);
        assertEquals("Read 1", 0, reader.read());
        assertEquals("Read 2", 1, reader.read());
        assertEquals("Skip 1", 5, reader.skip(5));
        assertEquals("Read 3", 7, reader.read());
        assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip
        assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file
        try {
            reader.skip(5); //
View Full Code Here

        Reader reader = new TestNullReader(10, true, false);
        assertEquals("Read 1", 0, reader.read());
        assertEquals("Read 2", 1, reader.read());
        assertEquals("Skip 1", 5, reader.skip(5));
        assertEquals("Read 3", 7, reader.read());
        assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip
        assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file
        try {
            reader.skip(5); //
            fail("Expected IOException for skipping after end of file");
        } catch (IOException e) {
View Full Code Here

        assertEquals("Read 1", 0, reader.read());
        assertEquals("Read 2", 1, reader.read());
        assertEquals("Skip 1", 5, reader.skip(5));
        assertEquals("Read 3", 7, reader.read());
        assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip
        assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file
        try {
            reader.skip(5); //
            fail("Expected IOException for skipping after end of file");
        } catch (IOException e) {
            assertEquals("Skip after EOF IOException message",
View Full Code Here

        assertEquals("Skip 1", 5, reader.skip(5));
        assertEquals("Read 3", 7, reader.read());
        assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip
        assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file
        try {
            reader.skip(5); //
            fail("Expected IOException for skipping after end of file");
        } catch (IOException e) {
            assertEquals("Skip after EOF IOException message",
                    "Skip after end of file",
                    e.getMessage());
View Full Code Here

    }

    /** Test {@link Reader#skip(long)}. */
    public void testSkip() throws IOException {
        Reader reader = new CharSequenceReader("FooBar");
        assertEquals(3, reader.skip(3));
        checkRead(reader, "Bar");
        assertEquals(-1, reader.skip(3));
        reader.reset();
        assertEquals(2, reader.skip(2));
        assertEquals(4, reader.skip(10));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.