Example usage for org.apache.commons.io.input CountingInputStream skip

List of usage examples for org.apache.commons.io.input CountingInputStream skip

Introduction

In this page you can find the example usage for org.apache.commons.io.input CountingInputStream skip.

Prototype

public long skip(final long length) throws IOException 

Source Link

Document

Skips the stream over the specified number of bytes, adding the skipped amount to the count.

Usage

From source file:com.playonlinux.win32.pe.PEReader.java

private static RsrcSection readResourceSection(CountingInputStream executableInputStream,
        SectionHeader[] sectionHeaders) throws IOException {
    SectionHeader rsrcSectionHeader = null;
    for (SectionHeader sectionHeader : sectionHeaders) {
        if (".rsrc\u0000\u0000\u0000".equals(new String(sectionHeader.name))) {
            rsrcSectionHeader = sectionHeader;
        }/*from   ww w.  j  a  v a2 s .c o  m*/
    }

    if (rsrcSectionHeader == null) {
        return null;
    }

    long numberToSkip = rsrcSectionHeader.pointerToRawData.getUnsignedValue()
            - executableInputStream.getCount();
    executableInputStream.skip(numberToSkip);
    byte[] rsrcSection = new byte[(int) rsrcSectionHeader.sizeOfRawData.getUnsignedValue()];
    executableInputStream.read(rsrcSection);

    return new RsrcSection(rsrcSection);
}

From source file:org.phoenicis.win32.pe.PEReader.java

private RsrcSection readResourceSection(CountingInputStream executableInputStream,
        SectionHeader[] sectionHeaders) throws IOException {
    SectionHeader rsrcSectionHeader = null;
    for (SectionHeader sectionHeader : sectionHeaders) {
        if (".rsrc\u0000\u0000\u0000".equals(new String(sectionHeader.name))) {
            rsrcSectionHeader = sectionHeader;
        }//from w w w.  j  av  a 2  s.  com
    }

    if (rsrcSectionHeader == null) {
        return null;
    }

    long numberToSkip = rsrcSectionHeader.pointerToRawData.getUnsignedValue()
            - executableInputStream.getCount();
    executableInputStream.skip(numberToSkip);
    byte[] rsrcSection = new byte[(int) rsrcSectionHeader.sizeOfRawData.getUnsignedValue()];
    executableInputStream.read(rsrcSection);

    return new RsrcSection(rsrcSection);
}

From source file:org.sead.repositories.reference.RefRepository.java

private static long skipTo(CountingInputStream cis, long curPos, Long long1) throws IOException {
    log.trace("Skipping to : " + long1.longValue());
    long offset = long1.longValue() - curPos;
    if (offset < 0) {
        log.error("Backwards jump attempted");
        throw new IOException("Backward Skip: failed");
    }//  w  w w.j a v a2  s .  co m
    log.trace("At: " + curPos + " going forward by " + offset);
    long curskip = 0;
    while (curskip < offset) {
        long inc = cis.skip(offset - curskip);
        if (inc == -1) {
            log.error("End of Stream");
            throw new IOException("End of Stream");
        }
        curskip += inc;
    }
    return offset;
}