### Question:
IoUtils { public static int safeRead(InputStream in) throws IOException { int i = in.read(); if (i < 0) { throw new EOFException(); } return i; } private  IoUtils(); static int safeRead(InputStream in); static int readShort(InputStream in); static int readUnsignedShort(InputStream in); static void writeShort(OutputStream out, int i); static void writeInt(OutputStream out, int i); static int readUnsignedMediumInt(InputStream in); static int readMediumInt(InputStream in); static int readInt(InputStream in); static long readUnsignedInt(InputStream in); static long readLong(InputStream in); static long readBinaryLengthEncoding(InputStream in); static long readBinaryLengthEncoding(InputStream in, int firstByte); static String readLengthCodedString(InputStream in, String charset); static String readLengthCodedString(InputStream in, int firstByte, String charset); static String readString(InputStream in, String charset); static String readFixedLengthString(InputStream in, int length, String charset); static Set<FieldFlag> readEnumSet(InputStream in, Class<FieldFlag> enumClass); static EnumSet<E> readEnumSetShort(InputStream in, Class<E> enumClass); static E readEnum(InputStream in, Class<E> enumClass); static void writeEnumSetShort(OutputStream out, Set<E> set); static final int NULL_VALUE; }### Answer:
@Test public void testSafeRead() throws IOException { InputStream in = new ByteArrayInputStream(new byte[] {0,1,2}); Assert.assertEquals(IoUtils.safeRead(in), 0); Assert.assertEquals(IoUtils.safeRead(in), 1); Assert.assertEquals(IoUtils.safeRead(in), 2); try { IoUtils.safeRead(in); Assert.fail("Did not throw EOF exception"); } catch (EOFException e) { } }