int readIntLittleEndian( ) { // get 4 unsigned byte components, and accumulate into an int. int accum = 0; for ( int shiftBy=0; shiftBy<32; shiftBy+=8 ) { accum |= ( readByte () & 0xff ) << shiftBy; } return accum; // rem in JDK 1.5+ you can say: // return Integer.reverseBytes( i ); }