Package java.io

Examples of java.io.InputStream.skip()


                }

                public int read(byte[] b, long position) throws IOException, RepositoryException {
                    InputStream in = getStream();
                    try {
                        in.skip(position);
                        return in.read(b);
                    } finally {
                        in.close();
                    }
                }
View Full Code Here


        assertEquals(result, "1234567890");
    }

    public void testSkip() throws IOException {
        InputStream in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 10L);
        assertEquals(10, in.skip(10));
        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 10L);
        in.read();
        assertEquals(9, in.skip(10));
View Full Code Here

        assertEquals(10, in.skip(10));
        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 10L);
        in.read();
        assertEquals(9, in.skip(10));
        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 2L);
        in.read();
        in.read();
View Full Code Here

        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 2L);
        in.read();
        in.read();
        assertTrue(in.skip(10) <= 0);
        assertTrue(in.skip(-1) == 0);
        assertTrue(in.read() == -1);
       
        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[2]), 4L);
        in.read();
View Full Code Here

        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 2L);
        in.read();
        in.read();
        assertTrue(in.skip(10) <= 0);
        assertTrue(in.skip(-1) == 0);
        assertTrue(in.read() == -1);
       
        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[2]), 4L);
        in.read();
        assertTrue(in.skip(2) == 1);
View Full Code Here

        assertTrue(in.skip(-1) == 0);
        assertTrue(in.read() == -1);
       
        in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[2]), 4L);
        in.read();
        assertTrue(in.skip(2) == 1);
    }

    public void testClose() throws IOException {
        String correct = "1234567890123456";
        InputStream in = new ContentLengthInputStream(new HttpDataReceiverMockup(
View Full Code Here

            public int read(byte[] b, long position) throws IOException, RepositoryException {
                InputStream in = getStream();
                try {
                    long skip = position;
                    while (skip > 0) {
                        long skipped = in.skip(skip);
                        if (skipped <= 0) {
                            return -1;
                        }
                        skip -= skipped;
                    }
View Full Code Here

        throws IOException
    {
        InputStream in = getInputStream();
        try
        {
            in.skip(start);
            if (count<0)
                IO.copy(in,out);
            else
                IO.copy(in,out,count);
        }
View Full Code Here

          assertEquals(new String(buf, 0, len, "UTF-8"), body.substring(0, len));

          is = b.openInputStream();
          got = 0;
          while (got < len) {
            int skipped = (int) is.skip(len - got);
            assertTrue(skipped > 0 && skipped <= (len - got),
                       "Invalid number of bytes skipped: " + skipped);
            got += skipped;
          }
View Full Code Here

                    // Get expected value
                    InputStream inStream = blob.getBinaryStream();
                    long left = blobLength - 100;
                    long read = 0;
                    while (left > 0 && read != -1) {
                        read = inStream.skip(Math.min(1024, left));
                        left -= read > 0? read : 0;
                    }
                    byte[] expected = new byte[100];
                    read = inStream.read(expected);
                    inStream.close();
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.