Excerpt from the Java DataInputStream class, showing parts of the byte alignment and ordering code, which are extremely slow. The DataOutputStream implementation has a similar problem.

Power Java
High-Performance Java Software Development
James Schatzman and Roy Donehower
Listing 1. Excerpt from the Java DataInputStream class, showing parts of the byte alignment and ordering code, which are extremely slow. The DataOutputStream implementation has a similar problem.


public final double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}
public final long readLong() throws IOException {
   InputStream in = this.in;
   return ((long) (readInt()) < 32)="" +="" (readint()="" &="" 0xffffffffl);="" }="" public="" final="" int="" readint()="" throws="" ioexception="" {="" inputstream="" in="this.in;" int="" ch1="in.read();" int="" ch2="in.read();" int="" ch3="in.read();" int="" ch4="in.read();" if="" ((ch1="" |="" ch2="" |="" ch3="" |="" ch4)="">< 0)="" throw="" new="" eofexception();="" return="" ((ch1="">< 24)="" +="" (ch2="">< 16)="" +="" (ch3="">< 8)="" +="" (ch4="">< 0));="" }="">

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025