Java examples for java.lang:String Hex
Convert string To Hex
//package com.java2s; public class Main { public static void main(String[] argv) { String str = "java2s.com"; System.out.println(stringToHex(str)); }/*from w w w . j a va 2 s .com*/ public static String stringToHex(String str) { char[] chars = str.toCharArray(); StringBuffer strBuffer = new StringBuffer(); for (int i = 0; i < chars.length; i++) { strBuffer.append(Integer.toHexString((int) chars[i])); } return strBuffer.toString(); } }