@Test void inputStream2Bytes() { assertNull(StringUtils.inputStream2Bytes(null)); String data = "abc\n" + ":\"klsdf\n" + "2ks,x:\".,-3sd˚ø≤ø¬≥"; byte[] bs = data.getBytes(Constants.DEFAULT_CHARSET); ByteArrayInputStream inputStream = new ByteArrayInputStream(data.getBytes(Constants.DEFAULT_CHARSET)); assertThat(StringUtils.inputStream2Bytes(inputStream)).isEqualTo(bs); }
public static byte[] inputStream2Bytes(InputStream is) { if (is == null) { return null; } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toByteArray(); } catch (Exception e) { throw new ShouldNeverHappenException(e); } }
StringUtils { public static byte[] inputStream2Bytes(InputStream is) { if (is == null) { return null; } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toByteArray(); } catch (Exception e) { throw new ShouldNeverHappenException(e); } } }
StringUtils { public static byte[] inputStream2Bytes(InputStream is) { if (is == null) { return null; } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toByteArray(); } catch (Exception e) { throw new ShouldNeverHappenException(e); } } private  StringUtils(); }
StringUtils { public static byte[] inputStream2Bytes(InputStream is) { if (is == null) { return null; } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toByteArray(); } catch (Exception e) { throw new ShouldNeverHappenException(e); } } private  StringUtils(); static boolean isNullOrEmpty(String str); static boolean isBlank(String str); static boolean isNotBlank(String str); static boolean equals(String a, String b); static boolean equalsIgnoreCase(String a, String b); static String inputStream2String(InputStream is); static byte[] inputStream2Bytes(InputStream is); static String toString(Object obj); }
StringUtils { public static byte[] inputStream2Bytes(InputStream is) { if (is == null) { return null; } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i = -1; while ((i = is.read()) != -1) { baos.write(i); } return baos.toByteArray(); } catch (Exception e) { throw new ShouldNeverHappenException(e); } } private  StringUtils(); static boolean isNullOrEmpty(String str); static boolean isBlank(String str); static boolean isNotBlank(String str); static boolean equals(String a, String b); static boolean equalsIgnoreCase(String a, String b); static String inputStream2String(InputStream is); static byte[] inputStream2Bytes(InputStream is); static String toString(Object obj); static final String EMPTY; }