@Override public double readDouble() throws IOException { fp += 8; double v = stream.readDouble(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
@Override public long readLong() throws IOException { fp += 8; long v = stream.readLong(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
@Override public long readLong() throws IOException { fp += 8; long v = stream.readLong(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
/** * Reverse the order of bytes in the given double. * * @param x double value to byte swap * @return double value resulting from byte swapping <code>x</code> */ public static double swap(double x) { return Double.longBitsToDouble(swap(Double.doubleToLongBits(x))); }
@Override public int readInt() throws IOException { fp += 4; int v = stream.readInt(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
@Override public double readDouble() throws IOException { fp += 8; double v = stream.readDouble(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
@Override public int readInt() throws IOException { fp += 4; int v = stream.readInt(); return order.equals(ByteOrder.LITTLE_ENDIAN) ? DataTools.swap(v) : v; }
/** * Reverse the order of bytes in the given float. * * @param x float value to byte swap * @return float value resulting from byte swapping <code>x</code> */ public static float swap(float x) { return Float.intBitsToFloat(swap(Float.floatToIntBits(x))); }
@Override public void writeByte(int v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeByte(v); }
@Override public void writeInt(int v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeInt(v); }
@Override public void writeDouble(double v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeDouble(v); }
@Override public void writeShort(int v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeShort(v); }
@Override public void write(int b) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) b = DataTools.swap(b); outStream.write(b); }
@Override public void writeByte(int v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeByte(v); }
@Override public void writeFloat(float v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeFloat(v); }
@Override public void writeInt(int v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeInt(v); }
@Override public void write(int b) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) b = DataTools.swap(b); outStream.write(b); }
@Override public void writeFloat(float v) throws IOException { if (outStream == null) { throw new HandleException("This stream is read-only."); } if (order.equals(ByteOrder.LITTLE_ENDIAN)) v = DataTools.swap(v); outStream.writeFloat(v); }