Example usage for com.google.common.io LittleEndianDataInputStream readFully

List of usage examples for com.google.common.io LittleEndianDataInputStream readFully

Introduction

In this page you can find the example usage for com.google.common.io LittleEndianDataInputStream readFully.

Prototype

@Override
    public void readFully(byte[] b) throws IOException 

Source Link

Usage

From source file:org.linguafranca.pwdb.kdbx.KdbxSerializer.java

private static void checkStartBytes(KdbxHeader kdbxHeader, InputStream decryptedInputStream)
        throws IOException {
    LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(decryptedInputStream);

    byte[] startBytes = new byte[32];
    ledis.readFully(startBytes);
    if (!Arrays.equals(startBytes, kdbxHeader.getStreamStartBytes())) {
        throw new IllegalStateException("Inconsistent stream bytes");
    }/*from w w w  . j a  v a2  s . c om*/
}

From source file:org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.java

private static void checkStartBytes(KdbxHeader kdbxHeader, InputStream decryptedInputStream)
        throws IOException {
    LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(decryptedInputStream);

    byte[] startBytes = new byte[32];
    ledis.readFully(startBytes);
    if (!Arrays.equals(startBytes, kdbxHeader.getStreamStartBytes())) {
        throw new IllegalStateException(
                "Inconsistent stream start bytes. This usually means the credentials were wromng.");
    }// w  w w  . j a v  a 2 s  .c  o  m
}

From source file:org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.java

private static byte[] getByteArray(LittleEndianDataInputStream ledis) throws IOException {
    short fieldLength = ledis.readShort();
    byte[] value = new byte[fieldLength];
    ledis.readFully(value);
    return value;
}

From source file:org.broad.igv.sam.cram.CRAMFile.java

public void readBlocks(InputStream is, int nBlocks) throws IOException {

    LittleEndianDataInputStream lis = new LittleEndianDataInputStream(is);
    for (int i = 0; i < nBlocks; i++) {

        int compressionMethod = lis.read();
        int contentType = lis.read();
        int contentId = ITF8.readUnsignedITF8(lis);
        int size = ITF8.readUnsignedITF8(lis);
        int rawSize = ITF8.readUnsignedITF8(lis);

        byte[] blockData = new byte[size];
        lis.readFully(blockData);

        blockData = uncompress(blockData, compressionMethod);

        String tmp = new String(blockData);

        if (major >= 3) {
            int checksum = CramInt.int32(lis);
        }/*from  ww w .  ja  va  2s .  co m*/
    }
}