Whitespace and Javadoc
import java.io.OutputStream;
/**
- * Utility code for dealing with different endian systems.
+ * Helps with different endian systems.
* <p>
* Different computer architectures adopt different conventions for
* byte ordering. In so-called "Little Endian" architectures (eg Intel),
* subsequent bytes at higher addresses. For "Big Endian" architectures
* (eg Motorola), the situation is reversed.
* This class helps you solve this incompatibility.
+ * </p>
* <p>
* Origin of code: Excalibur
+ * </p>
*
* @see org.apache.commons.io.input.SwappedDataInputStream
*/
*/
private static int read(final InputStream input) throws IOException {
final int value = input.read();
-
if (EOF == value) {
throw new EOFException("Unexpected EOF reached");
}
-
return value;
}
@@ -125,7 +125,6 @@ public static int readSwappedInteger(final InputStream input) throws IOException
final int value2 = read(input);
final int value3 = read(input);
final int value4 = read(input);
-
return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16) + ((value4 & 0xff) << 24);
}
@@ -192,9 +191,7 @@ public static long readSwappedUnsignedInteger(final byte[] data, final int offse
final long low = ((data[offset + 0] & 0xff) << 0) +
((data[offset + 1] & 0xff) << 8) +
((data[offset + 2] & 0xff) << 16);
-
final long high = data[offset + 3] & 0xff;
-
return (high << 24) + (0xffffffffL & low);
}
@@ -210,11 +207,8 @@ public static long readSwappedUnsignedInteger(final InputStream input) throws IO
final int value2 = read(input);
final int value3 = read(input);
final int value4 = read(input);
-
final long low = ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16);
-
final long high = value4 & 0xff;
-
return (high << 24) + (0xffffffffL & low);
}
