public static String string2Hex(String src) { StringBuffer sb = new StringBuffer(); try { for (byte b : src.getBytes("Windows-31J")) { String s = Integer.toHexString(0xff & b); if (s.length() == 1) { sb.append("0"); } sb.append(s); sb.append(" "); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } return sb.toString(); }