Java String to Hex convertStringToHex(String str)

Here you can find the source of convertStringToHex(String str)

Description

convert String To Hex

License

Open Source License

Declaration

public static String convertStringToHex(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String convertStringToHex(String str) {

        char[] chars = str.toCharArray();

        StringBuffer hex = new StringBuffer();
        for (int i = 0; i < chars.length; i++) {
            hex.append(Integer.toHexString((int) chars[i]));
        }//w w  w .j av a  2s  . c o  m

        return hex.toString();
    }
}

Related

  1. convertStringToHexComma(String plain, boolean appendNullSigns)
  2. convertStringtoHexFormat(String stringToConvert)
  3. convertStringToHexString(String data)