Package java.io

Examples of java.io.InputStream.skip()


    @Test
    public void testSkip() throws IOException {
        byte[] src = "HELLO MINA!".getBytes();
        ByteBuffer bb = ByteBuffer.wrap(src);
        InputStream is = new ByteBufferInputStream(bb);
        is.skip(6);

        assertEquals(5, is.available());
        assertEquals('M', is.read());
        assertEquals('I', is.read());
        assertEquals('N', is.read());
View Full Code Here


        assertEquals('M', is.read());
        assertEquals('I', is.read());
        assertEquals('N', is.read());
        assertEquals('A', is.read());

        is.skip((long) Integer.MAX_VALUE + 1);
        assertEquals(-1, is.read());
        is.close();
    }

}
View Full Code Here

    final int length = randomInt(data.length - offset);
    is = new LZ4BlockInputStream(open(compressed.toByteArray()), decompressor, checksum);
    restored = new byte[length + 1000];
    read = 0;
    while (read < offset) {
      final long skipped = is.skip(offset - read);
      assertTrue(skipped >= 0);
      read += skipped;
    }
    read = 0;
    while (read < length) {
View Full Code Here

        int attemptCount = 0;
        String s = "";
        while (attemptCount < MAX_ATTEMPT_COUNT) {
            in.mark(FOUR_KB + (int) nextPos);
            if (nextPos > 0) {
                long skipped = in.skip(nextPos);
                if (skipped != nextPos) {
                    break;
                }
            }
            byte[] buf = new byte[ONE_KB * 3];
 
View Full Code Here

        if (range != null) {
            partialLength = partialEnd - partialStart + 1;
            response.addHeader("Content-Range", "bytes " + partialStart + "-" + partialEnd + "/" + totalLength);
            if (partialStart > 0) {
                in.skip(partialStart);
            }
        }

        response.addHeader("Content-Length", "" + partialLength);
View Full Code Here

  }
 
  public synchronized InputStream getBlockInputStream(Block b, long seekOffset)
                              throws IOException {
    InputStream result = getBlockInputStream(b);
    result.skip(seekOffset);
    return result;
  }

  /** Not supported */
  public BlockInputStreams getTmpInputStreams(Block b, long blkoff, long ckoff
View Full Code Here

              // Try the next one
              // RuntimeException is iffy, so lets not try the hasher.
              continue;
            } catch (CompressionOutputSizeException e) {
              if(hasher != null) {
                is.skip(Long.MAX_VALUE);
                hashes = hasher.getResults();
                first = false;
              }
              continue; // try next compressor type
            }
View Full Code Here

                        in=resource.getInputStream();
                        pos=0;
                    }
                    if (pos<start)
                    {
                        in.skip(start-pos);
                        pos=start;
                    }
                    IO.copy(in,multi,size);
                    pos+=size;
                }
View Full Code Here

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            InputStream is = new ByteArrayInputStream( rawdata );
            Header header = new Header();
            header.read(rawdata, CHECKSUM_SIZE);
            is.skip(header.getSize() + CHECKSUM_SIZE);

            InflaterInputStream inflater = new InflaterInputStream( is );
            byte[] chunk = new byte[4096];
            int count;
            while ((count = inflater.read(chunk)) >=0 ) {
View Full Code Here

                        int b0 = b4[0] & 0xFF;
                        int b1 = b4[1] & 0xFF;
                        int b2 = b4[2] & 0xFF;
                        if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
                            // ignore first three bytes...
                            stream.skip(3);
                            /********
                            offset = 3;
                            count -= offset;
                            ***/
                        }
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.