### Question:
Util { public static byte[] bytes(InputStream in) throws IOException { if (in == null) { throw new IllegalArgumentException("input stream cannot be null"); } ByteArrayOutputStream os = null; try { os = new ByteArrayOutputStream(1024); byte[] bytes = new byte[1024]; int len; while ((len = in.read(bytes)) != -1) { os.write(bytes, 0, len); } return os.toByteArray(); } finally { closeQuietly(os); } } private  Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String charset); static String readFile(String fileName); static String readFile(String fileName, String charset); static void closeQuietly(AutoCloseable autoCloseable); static void closeQuietly(AutoCloseable ... autoCloseable); static void closeQuietly(List<T> autoCloseable); static String read(InputStream in); static String read(InputStream in, String charset); static byte[] bytes(InputStream in); static byte[] read(File file); static List<String> getResourceLines(String resourceName); static boolean blank(Object value); static boolean empty(Object[] array); static boolean empty(Collection<?> collection); static String join(String[] array, String delimiter); static String[] split(String input, String delimiters); static String[] split(String input, char delimiter); static String join(Collection<?> collection, String delimiter); static void join(StringBuilder sb, Collection<?> collection, String delimiter); static void join(StringBuilder sb, Object[] array, String delimiter); static void repeat(StringBuilder sb, String str, int count); static void joinAndRepeat(StringBuilder sb, String str, String delimiter, int count); static void saveTo(String path, InputStream in); static String getCauseMessage(Throwable throwable); static String getStackTraceString(Throwable throwable); static void saveTo(String path, byte[] content); static String toBase64(byte[] input); static byte[] fromBase64(String input); String[] arr(String ... params); static Properties readProperties(String fileOrResource); static boolean createTree(Path path); static void recursiveDelete(Path directory);  }### Answer:
@Test public void shouldReadBytesFromStream() throws IOException { byte[] bytes = Util.bytes(UtilTest.class.getResourceAsStream("/text.txt")); a(new String(bytes)).shouldBeEqual("hello"); }