Here you can find the source of toHexString(String input)
private static String toHexString(String input)
//package com.java2s; /**//from w ww . j av a 2 s. c o m * Confidential Information. * Copyright (C) 2007-2009 Eric Link, All rights reserved. * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. **/ public class Main { private static String toHexString(String input) { StringBuffer sb = new StringBuffer(); byte[] bytes = input.getBytes(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i]); if (hex.length() == 1) { sb.append("0"); } else if (hex.length() > 2) { hex = hex.substring(hex.length() - 2, hex.length()); } sb.append(hex); sb.append(" "); } return sb.toString(); } }