StringUtil { public static String toHexString(byte[] byteArray, String delim) { if (delim == null) { delim = ""; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < byteArray.length; i++) { if (i > 0) { sb.append(delim); } String hex = Integer.toHexString(byteArray[i] & 0x00ff) .toUpperCase(); if (hex.length() < 2) { sb.append("0"); } sb.append(hex); } return sb.toString(); }  static boolean isWhitespace(char c); static boolean isZenHankakuSpace(char c); static String rtrim(String str); static String ltrim(String str); static String trim(String str); static String rtrimZ(String str); static String ltrimZ(String str); static String trimZ(String str); static String toShortClassName(String longClassName); static String getExtension(String name); static String toHexString(byte[] byteArray, String delim); static String capitalizeInitial(String str); static String[] parseCSV(String csvString); static String[] parseCSV(String csvString, String escapeString); static String dump(Map<?, ?> map); static String getArraysStr(Object[] arrayObj); static String hankakuToZenkaku(String value); static String zenkakuToHankaku(String value); static String filter(String str); static String toLikeCondition(String condition); static int getByteLength(String value, String encoding); static final String LINE_SEP; static final String LIKE_ESC_CHAR; }
@Test public void testToHexString01() throws Exception { byte[] byteArray = { 0 }; String result = StringUtil.toHexString(byteArray, "-"); assertEquals("00", result); }
@Test public void testToHexString02() throws Exception { byte[] byteArray = {}; String result = StringUtil.toHexString(byteArray, "-"); assertEquals("", result); }
@Test public void testToHexString03() throws Exception { byte[] byteArray = { 0, 10, 100 }; String result = StringUtil.toHexString(byteArray, "/"); assertEquals("00/0A/64", result); }
@Test public void testToHexString04() throws Exception { byte[] byteArray = { 0, 10, 100 }; String result = StringUtil.toHexString(byteArray, ""); assertEquals("000A64", result); }
@Test public void testToHexString05() throws Exception { byte[] byteArray = { 0, 10, 100 }; String result = StringUtil.toHexString(byteArray, null); assertEquals("000A64", result); }
@Test public void testToHexString06() throws Exception { byte[] byteArray = null; try { StringUtil.toHexString(byteArray, "/"); fail(); } catch (NullPointerException e) { return; } }