Package java.io

Examples of java.io.Reader.reset()


        checkRead(reader, "Bar");
        reader.reset();
        checkRead(reader, "Bar");
        reader.close();
        checkRead(reader, "Foo");
        reader.reset();
        checkRead(reader, "Foo");
    }

    /** Test {@link Reader#skip(long)}. */
    public void testSkip() throws IOException {
View Full Code Here


    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));
        assertEquals(-1, reader.skip(1));
        reader.close();
        assertEquals(6, reader.skip(20));
View Full Code Here

        chars)), 12);
    try {
      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);
    } catch (IOException e) {
      fail("Exception during mark test 2:" + e);
    }
View Full Code Here

    in = new BufferedReader(new Support_StringReader(new String(chars)), 12);
    try {
      in.skip(6);
      in.mark(8);
      in.skip(7);
      in.reset();
      assertTrue("Wrong chars 2", in.read() == (char) 6
          && in.read() == (char) 7);
    } catch (IOException e) {
      fail("Exception during mark test 3:" + e);
    }
View Full Code Here

    public ReadableRepresentation readRepresentation(Reader reader) {
        try {
            Reader bufferedReader = new BufferedReader(reader);
            bufferedReader.mark(1);
            char firstChar = (char) bufferedReader.read();
            bufferedReader.reset();

            Class<? extends RepresentationReader> readerClass;
            switch (firstChar) {
                case '{':
                    readerClass = representationReaders.get(new ContentType(HAL_JSON));
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

            // 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();
            }

            XHTMLContentHandler xhtml =
                new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();
View Full Code Here

            // 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();
            }

            XHTMLContentHandler xhtml =
                new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();
View Full Code Here

                        caw.append((char)c);
                    }
                } catch (IOException ignored) {
                }
                caw.close();
                try{ rdr.reset();} catch(IOException ignored) {}
                ret = new SAXSource(new InputSource(new CharArrayReader(caw.toCharArray())));
            } else {
                ret = new SAXSource();
            }
        } else if(src instanceof StreamSource) {
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.