Code example for DataInputStream

Methods: readreadBytereadInt

0
 
        int sectorNumber = offset >> 8;
        int numSectors = offset & 0xFF;
 
        stream.seek(sectorNumber * SECTOR_BYTES);
        int length = dataStream.readInt();
 
        if (length > SECTOR_BYTES * numSectors) {
            throw new DataException("MCRegion chunk at " 
                    + x + "," + z + " has an invalid length of " + length);
        } 
 
        byte version = dataStream.readByte();
 
        if (version == VERSION_GZIP) {
            byte[] data = new byte[length - 1];
            if (dataStream.read(data) < length - 1) {
                throw new DataException("MCRegion file does not contain " 
                        + x + "," + z + " in full");
            } 
            return new GZIPInputStream(new ByteArrayInputStream(data));
        } else if (version == VERSION_DEFLATE) {
            byte[] data = new byte[length - 1];
            if (dataStream.read(data) < length - 1) {
                throw new DataException("MCRegion file does not contain " 
                        + x + "," + z + " in full");
            } 
            return new InflaterInputStream(new ByteArrayInputStream(data));
        } else { 
Connect your IDE to all the code out there  Get Codota for Java