### Question:
IoUtils { public static String readString(InputStream in, String charset) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); int c; while ((c = in.read()) > 0) { out.write(c); } return new String(out.toByteArray(), charset); } 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 readString() throws IOException { final String first = "Hi there"; final String second = "Have a nice day!"; byte[] firstBytes = first.getBytes(); byte[] secondBytes = second.getBytes(); byte[] newBytes = new byte[firstBytes.length + secondBytes.length + 1]; System.arraycopy(firstBytes, 0, newBytes, 0, firstBytes.length); System.arraycopy(secondBytes, 0, newBytes, firstBytes.length + 1, secondBytes.length); InputStream in = new ByteArrayInputStream(newBytes); Assert.assertEquals(IoUtils.readString(in, "UTF-8"), first); Assert.assertEquals(IoUtils.readString(in, "UTF-8"), second); }