### Question:
StringUtil { public static String str2HexStr(String str) { char[] chars = "0123456789ABCDEF".toCharArray(); StringBuilder sb = new StringBuilder(""); byte[] bs = str.getBytes(); for (int i = 0; i < bs.length; i++) { int bit = (bs[i] & 0xF0) >> 4; sb.append(chars[bit]); bit = bs[i] & 0xF; sb.append(chars[bit]); } return sb.toString(); }  static String getMiddleString(String text, String lStr, String rStr); static String deleteCRLFOnce(String input); static String str2HexStr(String str); static String hexStr2Str(String hexStr); static String byte2HexStr(byte[] b); static byte[] hexStr2Bytes(String src); static String str2Unicode(String strText); static String unicode2Str(String hex); static String delTagsFContent(String content); static String formatSize(double size); static String getEncoding(byte[] bytes); static List<Node> getFileList(Torrent torrent); static CodepageDetectorProxy detector; }### Answer:
@Test public void testStr2HexStr() { assertEquals("666F6F", StringUtil.str2HexStr("foo")); }