StringHelper { public static byte[] getBytes(String s) { if (s == null) { return new byte[0]; } try { return s.getBytes(charset); } catch (UnsupportedEncodingException e) { return new byte[0]; } }  static String appendSlant(String url); static byte[] getBytes(String s); static String getString(byte[] bytes); static String[] mergeArray(String[] a, String[] b); static String[] emptyArray(); static String emptyString(); static boolean isEmpty(String s); static boolean isEmpty(String[] s); static String[] checkEmpty(String[] s); static String isEmpty(String value, String defaultValue); static String[] split(String s); static List<String> splitToList(String s);  }
@Test public void getBytes() throws UnsupportedEncodingException { Assert.assertEquals(0, StringHelper.getBytes(null).length); byte[] bytes = "test".getBytes("UTF-8"); byte[] testBytes = StringHelper.getBytes("test"); Assert.assertArrayEquals(bytes, testBytes); }