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

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

Introduction

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

Prototype

@Override
    public int readUnsignedByte() throws IOException 

Source Link

Usage

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

public static CRAMFile openFile(String path) throws IOException {

    SeekableStream stream = IGVSeekableStreamFactory.getInstance().getStreamFor(path);

    LittleEndianDataInputStream lis = new LittleEndianDataInputStream(stream);

    byte[] mn = new byte[4];
    for (int i = 0; i < 4; i++) {
        mn[i] = lis.readByte();// w  w w  .  ja  v  a  2  s.  c o m
    }
    String magicNumber = new String(mn);

    int majorFormatNumber = lis.readUnsignedByte();
    int minorFormatNumber = lis.readUnsignedByte();

    byte[] fileId = new byte[20];

    for (int i = 0; i < 20; i++) {
        fileId[i] = lis.readByte();
    }

    String fileName = new String(fileId);

    return new CRAMFile(path, majorFormatNumber, minorFormatNumber, fileName);
}