String stringToHex(final String in) { StringBuilder out = new StringBuilder(in.length() * 2); for (int i = 0; i < in.length(); i++) { out.append(Integer.toHexString(in.charAt(i))); } return out.toString(); }
Programming Tips - Java: Convert a String into its equivalent ASCII hex characters
Date: 2011sep28
Language: Java
Q. Java: Convert a String into its equivalent ASCII hex characters
A. Here's a function that efficiently does that: