StringUtil { public static String toString(final byte[] bytes) { try { return new String(bytes, CommonConstants.UTF_8); } catch (final UnsupportedEncodingException e) { throw new RuntimeException("Unable to convert bytes to string", e); } } private  StringUtil(); static String toString(final byte[] bytes); static byte[] toBytes(final String string); static String escapeComma(final String str); static String unescapeComma(final String escapedStr); static byte[] toCsv(final Class<?>... classes); static Set<Class<? extends T>> csvToClasses(final byte[] bytes, final Class<? extends T> clazz); static String nullIfEmpty(final String string); static final char COMMA; }
@Test public void toStringWhenBytesAreValid() { final byte[] validBytes = "isValid".getBytes(); assertEquals("isValid", StringUtil.toString(validBytes)); }