Here you can find the source of str2HexStrExt(String str)
public static String str2HexStrExt(String str)
//package com.java2s; public class Main { public static String str2HexStrExt(String str) { char[] chars = "0123456789ABCDEF".toCharArray(); StringBuilder sb = new StringBuilder(""); byte[] bs = str.getBytes(); int bit;//from w w w . j a v a 2 s.c o m for (int i = 0; i < bs.length; i++) { bit = (bs[i] & 0x0f0) >> 4; sb.append(chars[bit]); bit = bs[i] & 0x0f; sb.append(chars[bit]); } return sb.toString(); } }