Package java.io

Examples of java.io.Reader.reset()


              // Additional text is no longer at the start of the line
              startOfLine = false;
              continue;
            } else {
              // Only one
              br.reset();
            }
          }
          onlywhitespace = onlywhitespace && (c == ' ' || c == '\t' || c == '\r');
          out.append((char) c);
        }
View Full Code Here


        chars)), 12);

    in.skip(6);
    in.mark(14);
    in.read(new char[14], 0, 14);
    in.reset();
    assertTrue("Wrong chars", in.read() == (char) 6
        && in.read() == (char) 7);

    in = new BufferedReader(new Support_StringReader(new String(chars)), 12);
    in.skip(6);
View Full Code Here

    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);
        br.mark(3);
View Full Code Here

        char[] array = new char[3];
        assertEquals(3, reader.read(array, 0, 3));
        assertEquals('o', array[0]);
        assertEquals('m', array[1]);
        assertEquals('e', array[2]);
        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));
View Full Code Here

        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

       
        assertTrue("Mark Should be Supported", reader.markSupported());

        // No Mark
        try {
            reader.reset();
            fail("Read limit exceeded, expected IOException ");
        } catch (IOException e) {
            assertEquals("No Mark IOException message",
                         "No position has been marked",
                         e.getMessage());
View Full Code Here

        for (int i = 0; i < 3; i++) {
            assertEquals("Read After Mark [" + i +"]"(position + i), reader.read());
        }

        // Reset
        reader.reset();

        // Read From marked position
        for (int i = 0; i < readlimit + 1; i++) {
            assertEquals("Read After Reset [" + i +"]"(position + i), reader.read());
        }
View Full Code Here

            assertEquals("Read After Reset [" + i +"]"(position + i), reader.read());
        }

        // Reset after read limit passed
        try {
            reader.reset();
            fail("Read limit exceeded, expected IOException ");
        } catch (IOException e) {
            assertEquals("Read limit IOException message",
                         "Marked position [" + position
                         + "] is no longer valid - passed the read limit ["
View Full Code Here

        } catch (UnsupportedOperationException e) {
            assertEquals("mark() error message""Mark not supported", e.getMessage());
        }

        try {
            reader.reset();
            fail("reset() should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            assertEquals("reset() error message""Mark not supported", e.getMessage());
        }
    }
View Full Code Here

    public void testMark() throws IOException {
        Reader reader = new CharSequenceReader("FooBar");
        checkRead(reader, "Foo");
        reader.mark(0);
        checkRead(reader, "Bar");
        reader.reset();
        checkRead(reader, "Bar");
        reader.close();
        checkRead(reader, "Foo");
        reader.reset();
        checkRead(reader, "Foo");
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.