/** * Reads a "long" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); }
/** * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. * @return the read long * @throws EOFException if an end of file is reached unexpectedly * @throws IOException if an I/O error occurs */ @Override public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(final InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** @see java.io.DataInput#readInt() */ public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(byte[] data, int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
@Test public void testReadSwappedInteger() throws IOException { final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; assertEquals( 0x01020304, EndianUtils.readSwappedInteger( bytes, 0 ) ); final ByteArrayInputStream input = new ByteArrayInputStream(bytes); assertEquals( 0x01020304, EndianUtils.readSwappedInteger( input ) ); }
/** * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. * @return the read long * @throws EOFException if an end of file is reached unexpectedly * @throws IOException if an I/O error occurs */ public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
/** * Reads a "long" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); }
/** * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. * @return the read long * @throws EOFException if an end of file is reached unexpectedly * @throws IOException if an I/O error occurs */ @Override public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
/** * Reads a "long" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static long readSwappedLong(final byte[] data, final int offset) { final long low = readSwappedInteger(data, offset); final long high = readSwappedInteger(data, offset + 4); return (high << 32) + (0xffffffffL & low); }
/** * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. * @return the read long * @throws EOFException if an end of file is reached unexpectedly * @throws IOException if an I/O error occurs */ public int readInt() throws IOException, EOFException { return EndianUtils.readSwappedInteger( in ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(byte[] data, int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(final InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(byte[] data, int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }
/** * Reads a "float" value from a byte array at a given offset. The value is * converted to the opposed endian system while reading. * @param data source byte array * @param offset starting offset in the byte array * @return the value read */ public static float readSwappedFloat(final byte[] data, final int offset) { return Float.intBitsToFloat( readSwappedInteger( data, offset ) ); }
/** * Reads a "float" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static float readSwappedFloat(final InputStream input) throws IOException { return Float.intBitsToFloat( readSwappedInteger( input ) ); }