Refine search
/** * Reads a {@code float} as specified by {@link DataInputStream#readFloat()}, except using * little-endian byte order. * * @return the next four bytes of the input stream, interpreted as a {@code float} in * little-endian byte order * @throws IOException if an I/O error occurs */ @CanIgnoreReturnValue // to skip some bytes @Override public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
/** * Reads a {@code double} as specified by {@link DataInputStream#readDouble()}, except using * little-endian byte order. * * @return the next eight bytes of the input stream, interpreted as a {@code double} in * little-endian byte order * @throws IOException if an I/O error occurs */ @CanIgnoreReturnValue // to skip some bytes @Override public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
public void open(InputStream stream) { close(); if (stream != null) { // We need to explicitly cast to DataInput as otherwise the constructor is ambiguous. // We choose DataInput instead of InputStream as ExtDataInput wraps an InputStream in // a DataInputStream which is big-endian and ignores the little-endian behavior. m_reader = new ExtDataInput((DataInput) new LittleEndianDataInputStream(stream)); } }
/** * Reads a {@code long} as specified by {@link DataInputStream#readLong()}, except using * little-endian byte order. * * @return the next eight bytes of the input stream, interpreted as a {@code long} in * little-endian byte order * @throws IOException if an I/O error occurs */ @CanIgnoreReturnValue // to skip some bytes @Override public long readLong() throws IOException { byte b1 = readAndCheckByte(); byte b2 = readAndCheckByte(); byte b3 = readAndCheckByte(); byte b4 = readAndCheckByte(); byte b5 = readAndCheckByte(); byte b6 = readAndCheckByte(); byte b7 = readAndCheckByte(); byte b8 = readAndCheckByte(); return Longs.fromBytes(b8, b7, b6, b5, b4, b3, b2, b1); }
@CanIgnoreReturnValue // to skip a byte @Override public boolean readBoolean() throws IOException { return readUnsignedByte() != 0; }
/** * Reads a {@code short} as specified by {@link DataInputStream#readShort()}, except using * little-endian byte order. * * @return the next two bytes of the input stream, interpreted as a {@code short} in little-endian * byte order. * @throws IOException if an I/O error occurs. */ @CanIgnoreReturnValue // to skip some bytes @Override public short readShort() throws IOException { return (short) readUnsignedShort(); }
public static Origin read (InputStream inputStream) throws IOException { LittleEndianDataInputStream data = new LittleEndianDataInputStream(inputStream); header[i] = (char) data.readByte(); int version = data.readInt(); origin.jobId = data.readUTF(); origin.percentile = data.readDouble(); origin.x = data.readInt(); origin.y = data.readInt(); origin.samples = new int[data.readInt()]; origin.samples[iteration] = data.readInt(); data.close();
public Grid compute (InputStream rawInput) throws IOException { LittleEndianDataInputStream input = new LittleEndianDataInputStream(new GZIPInputStream(rawInput)); header[i] = (char) input.readByte(); int version = input.readInt(); int zoom = input.readInt(); int west = input.readInt(); int north = input.readInt(); int width = input.readInt(); int height = input.readInt(); int nSamples = input.readInt(); valuesThisOrigin[iteration] = (val += input.readInt()); input.close(); return outputGrid;
/** * Warning: the result is negative in Java if UInt32 > 0x7fffffff * @return next UInt32 value as an int * @throws IOException */ public int readUInt32AsInt() throws IOException { return in.readInt(); }
/** * Warning: the result is negative in Java if UInt64 > 0x7fffffffffffffff * @return next UInt64 value as a long * @throws IOException */ public long readUInt64AsLong() throws IOException { return in.readLong(); }
/** * Reads a {@code short} as specified by {@link DataInputStream#readShort()}, * except using little-endian byte order. * * @return the next two bytes of the input stream, interpreted as a * {@code short} in little-endian byte order. * @throws IOException if an I/O error occurs. */ @Override public short readShort() throws IOException { return (short) readUnsignedShort(); }
@Override public CrxMetadata parseMetadata(InputStream crxInput) throws IOException { String magicNumber = readMagicNumber(crxInput); checkMagicNumber(magicNumber); LittleEndianDataInputStream in = new LittleEndianDataInputStream(crxInput); int version = Ints.checkedCast(UnsignedInteger.fromIntBits(in.readInt()).longValue()); CrxInterpreter interpreter = getCrxInterpreter(magicNumber, version); CrxMetadata metadata = interpreter.parseMetadataAfterVersion(crxInput); return metadata; }
private static void validateHeaderAndVersion(LittleEndianDataInputStream input) throws IOException { char[] header = new char[8]; for (int i = 0; i < 8; i++) { header[i] = (char) input.readByte(); } if (!"ACCESSGR".equals(new String(header))) { throw new IllegalArgumentException("Input not in access grid format!"); } int version = input.readInt(); if (version != ACCESS_GRID_VERSION) { throw new IllegalArgumentException(String.format("Version mismatch of access grids, expected %s, found %s", ACCESS_GRID_VERSION, version)); } }
@Override public boolean readBoolean() throws IOException { return readUnsignedByte() != 0; }
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 wrong."); } }
/** * Reads an unsigned {@code short} as specified by * {@link DataInputStream#readUnsignedShort()}, except using little-endian * byte order. * * @return the next two bytes of the input stream, interpreted as an * unsigned 16-bit integer in little-endian byte order * @throws IOException if an I/O error occurs */ @Override public int readUnsignedShort() throws IOException { byte b1 = readAndCheckByte(); byte b2 = readAndCheckByte(); return Ints.fromBytes((byte) 0, (byte) 0, b2, b1); }
/** * Warning: the result is negative in Java if UInt8 > 0x7f * @return next UInt8 value as a byte * @throws IOException */ public byte readUInt8AsByte() throws IOException { return in.readByte(); }
/** * Reads an integer as specified by {@link DataInputStream#readInt()}, except using little-endian * byte order. * * @return the next four bytes of the input stream, interpreted as an {@code int} in little-endian * byte order * @throws IOException if an I/O error occurs */ @CanIgnoreReturnValue // to skip some bytes @Override public int readInt() throws IOException { byte b1 = readAndCheckByte(); byte b2 = readAndCheckByte(); byte b3 = readAndCheckByte(); byte b4 = readAndCheckByte(); return Ints.fromBytes(b4, b3, b2, b1); }
@CanIgnoreReturnValue // to skip a byte @Override public byte readByte() throws IOException { return (byte) readUnsignedByte(); }