Here you can find the source of stringToHex(String str)
Parameter | Description |
---|---|
str | The String to convert. |
public static String stringToHex(String str)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.DatatypeConverter; public class Main { /**/*from w ww . ja v a 2 s . c o m*/ * Converts a {@code String} to hexadecimal. * * @param str The {@code String} to convert. * @return A {@code String} containing a hexadecimal equivalent of the given * lexical argument. */ public static String stringToHex(String str) { byte bytes[] = str.getBytes(); return DatatypeConverter.printHexBinary(bytes); } }