/** * Read one int from the input. * @return the read number * @throws java.io.IOException If there is IO error. * @throws java.io.EOFException If end of file reached. */ public int readInt() throws IOException { int val = 0; int shift = 0; int b = readByte(); while (b > 0x7f) { val ^= (b & 0x7f) << shift; shift += 7; b = readByte(); } val ^= b << shift; return (val >>> 1) ^ -(val & 1); }
/** * Read one long int from the input. * @return the read number * @throws java.io.IOException If there is IO error. * @throws java.io.EOFException If end of file reached. */ public long readLong() throws IOException { long val = 0; int shift = 0; int b = readByte(); while (b > 0x7f) { val ^= (long) (b & 0x7f) << shift; shift += 7; b = readByte(); } val ^= (long) b << shift; return (val >>> 1) ^ -(val & 1); }