Here you can find the source of toASCII(String str)
public static String toASCII(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String toASCII(String str) { StringBuffer strBuf = new StringBuffer(); byte[] bGBK = str.getBytes(); for (int i = 0; i < bGBK.length; i++) { strBuf.append(Integer.toHexString(bGBK[i] & 0xff)); }/*from www . ja va 2s. c o m*/ return strBuf.toString(); } public static String toString(Object object) { return toString(object, null); } public static String toString(Object object, String defaultValue) { if (object == null) return defaultValue; return String.valueOf(object); } }