Package java.io

Examples of java.io.Reader.mark()


            continue;
          }
          sawCR = false;
          // Check for a mustache start
          if (c == sm.charAt(0)) {
            br.mark(1);
            if (sm.length() == 1 || br.read() == sm.charAt(1)) {
              // Two mustaches, now capture command
              StringBuilder sb = new StringBuilder();
              while ((c = br.read()) != -1) {
                br.mark(1);
View Full Code Here


            br.mark(1);
            if (sm.length() == 1 || br.read() == sm.charAt(1)) {
              // Two mustaches, now capture command
              StringBuilder sb = new StringBuilder();
              while ((c = br.read()) != -1) {
                br.mark(1);
                if (c == em.charAt(0)) {
                  if (em.length() > 1) {
                    if (br.read() == em.charAt(1)) {
                      // Matched end
                      break;
View Full Code Here

    /** Test {@link Reader#mark(int)}. */
    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");
View Full Code Here

        try {
            Reader reader =
                new BufferedReader(new InputStreamReader(stream, encoding));

            // TIKA-240: Drop the BOM when extracting plain text
            reader.mark(1);
            int bom = reader.read();
            if (bom != '\ufeff') { // zero-width no-break space
                reader.reset();
            }
View Full Code Here

        for (; position < 3; position++) {
            assertEquals("Read Before Mark [" + position +"]",  position, reader.read());
        }

        // Mark
        reader.mark(readlimit);

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

    public void testMarkNotSupported() throws Exception {
        Reader reader = new TestNullReader(100, false, true);
        assertFalse("Mark Should NOT be Supported", reader.markSupported());

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

    /** Test {@link Reader#mark(int)}. */
    @Test
    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");
View Full Code Here

        assertEquals(0, reader.skip(-1));
       
        assertEquals(true, reader.markSupported());
        reader = sb.asReader();
        assertEquals('s', reader.read());
        reader.mark(-1);
        char[] array = new char[3];
        assertEquals(3, reader.read(array, 0, 3));
        assertEquals('o', array[0]);
        assertEquals('m', array[1]);
        assertEquals('e', array[2]);
View Full Code Here

      int read;
      read = reader.read(cc);
      assertEquals(6, read);
      assertEquals("Quick ", new String(cc));
     
      reader.mark(100);
     
      read = reader.read(cc);
      assertEquals(6, read);
      assertEquals("brown ", new String(cc));
     
View Full Code Here

                    url = null; // Don't bother user with generic IRI syntax
                    Reader reader = new BufferedReader(
                            new Utf8PercentDecodingReader(new StringReader(
                                    "function(event){" + tail.toString() + "}")));
                    // XXX CharSequenceReader
                    reader.mark(1);
                    int c = reader.read();
                    if (c != 0xFEFF) {
                        reader.reset();
                    }
                    try {
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.