Here you can find the source of asciiToHex(String ascii)
public static String asciiToHex(String ascii)
//package com.java2s; //License from project: Open Source License public class Main { public static String asciiToHex(String ascii) { if (ascii == null) throw new NullPointerException(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ascii.length(); i++) { int asciiCode = ascii.charAt(i) & 0xFF; sb.append(String.format("%02x", asciiCode)); }// www. j a v a 2 s.c o m return sb.toString(); } }