@Test public void testArrayEmptyByteArray() throws Exception { byte[] s = IoUtils.toByteArray(new ByteArrayInputStream(new byte[0])); assertEquals(0, s.length); }
public static byte[] toByteArray(InputStream is) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { byte[] b = new byte[BUFFER_SIZE]; int n; while ((n = is.read(b)) != -1) { output.write(b, 0, n); } return output.toByteArray(); } catch (IOException e) { throw new UncheckedIOException(e); } }
IoUtils { public static byte[] toByteArray(InputStream is) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { byte[] b = new byte[BUFFER_SIZE]; int n; while ((n = is.read(b)) != -1) { output.write(b, 0, n); } return output.toByteArray(); } catch (IOException e) { throw new UncheckedIOException(e); } } }
IoUtils { public static byte[] toByteArray(InputStream is) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { byte[] b = new byte[BUFFER_SIZE]; int n; while ((n = is.read(b)) != -1) { output.write(b, 0, n); } return output.toByteArray(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  IoUtils(); }
IoUtils { public static byte[] toByteArray(InputStream is) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { byte[] b = new byte[BUFFER_SIZE]; int n; while ((n = is.read(b)) != -1) { output.write(b, 0, n); } return output.toByteArray(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  IoUtils(); static byte[] toByteArray(InputStream is); static String toUtf8String(InputStream is); static String readUtf8File(String path); static String readUtf8File(Path path); static String readUtf8Resource(ClassLoader classLoader, String resourcePath); static String readUtf8Resource(Class<?> clazz, String resourcePath); static String readUtf8Url(URL url); static String runCommand(String command); static String runCommand(String command, Path directory); static int runCommand(String command, Path directory, Appendable output); }
IoUtils { public static byte[] toByteArray(InputStream is) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { byte[] b = new byte[BUFFER_SIZE]; int n; while ((n = is.read(b)) != -1) { output.write(b, 0, n); } return output.toByteArray(); } catch (IOException e) { throw new UncheckedIOException(e); } } private  IoUtils(); static byte[] toByteArray(InputStream is); static String toUtf8String(InputStream is); static String readUtf8File(String path); static String readUtf8File(Path path); static String readUtf8Resource(ClassLoader classLoader, String resourcePath); static String readUtf8Resource(Class<?> clazz, String resourcePath); static String readUtf8Url(URL url); static String runCommand(String command); static String runCommand(String command, Path directory); static int runCommand(String command, Path directory, Appendable output);  }