Package java.io

Examples of java.io.Reader.skip()


        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 static long getContentLength(ClientResponse response) {
        // getContentLenght returns -1
        // contentLength = response.getContentLength();
        try {
            Reader reader = response.getReader();
            long actualSkip = reader.skip(Long.MAX_VALUE);
            return actualSkip;
        } catch (IOException e) {
        }
        return -1L;
    }
View Full Code Here

            }
            long pos = 1;
            while (remaining > 0) {
                String str = clob.getSubString(
                        pos, Math.min(MAX_BSIZE, remaining));
                myReader.skip(Math.min(MAX_BSIZE, remaining) -1);
                pos += str.length();
                remaining -= str.length();
                // Avoid failure on the last char when Clob is modified.
                if (!modifyClob || remaining != 0) {
                    assertEquals(myReader.read(), str.charAt(str.length() -1));
View Full Code Here

        stmt.close();
        assertEquals (sb.length(), clob.length());
        Reader r = clob.getCharacterStream();
        String newString = "this is a new string";
        //access reader before modifying the clob
        long l = r.skip (100);
        clob.setString (1001, newString);
        //l chars are already skipped
        long toSkip = 1000 - l;
        while (toSkip > 0) {
            long skipped = r.skip (toSkip);
View Full Code Here

        long l = r.skip (100);
        clob.setString (1001, newString);
        //l chars are already skipped
        long toSkip = 1000 - l;
        while (toSkip > 0) {
            long skipped = r.skip (toSkip);
            toSkip -= skipped;
        }
        char [] newdata = new char [newString.length()];
        int len = r.read(newdata);
        assertEquals ("updated not reflected", newString,
View Full Code Here

                            String.valueOf (clobData), sb.toString());
        r.close();
        //update before gettting the reader
        clob.setString (50, dummy);
        r = clob.getCharacterStream();
        r.skip (49);
        char [] newChars = new char [dummy.length()];
        r.read (newChars);
        assertEquals ("update not reflected", dummy,
                                    String.valueOf (newChars));
        //update again and see if stream is refreshed
View Full Code Here

        r.read (newChars);
        assertEquals ("update not reflected", dummy,
                                    String.valueOf (newChars));
        //update again and see if stream is refreshed
        clob.setString (75, dummy);
        r.skip (75 - 50 - dummy.length());
        char [] testChars = new char [dummy.length()];
        r.read (testChars);
        assertEquals ("update not reflected", dummy,
                                    String.valueOf (newChars));
        r.close();
View Full Code Here

        //try inserting some unicode string
        String unicodeStr = getUnicodeString();
        clob.setString (50, unicodeStr);
        char [] utf16Chars = new char [unicodeStr.length()];
        r = clob.getCharacterStream();
        r.skip(49);
        r.read(utf16Chars);
        assertEquals ("update not reflected",  unicodeStr,
                                    String.valueOf (utf16Chars));
        r.close();
        Writer w = clob.setCharacterStream (1);
View Full Code Here

        for (int i = 0; i < 10000; i++) {
            w.write (dummy);
        }
        w.close();
        clob.setString (500, unicodeStr);
        r.skip (499);
        char [] unicodeChars = new char [unicodeStr.length()];
        r.read (unicodeChars);
        assertEquals ("update not reflected",  unicodeStr,
                                    String.valueOf (unicodeChars));
    }
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.