Java ASCII to Hex asciiToHex(String ascii)

Here you can find the source of asciiToHex(String ascii)

Description

ascii To Hex

License

Open Source License

Declaration

public static String asciiToHex(String ascii) 

Method Source Code

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

public class Main {
    public static String asciiToHex(String ascii) {
        if (ascii == null)
            throw new NullPointerException();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < ascii.length(); i++) {
            int asciiCode = ascii.charAt(i) & 0xFF;
            sb.append(String.format("%02x", asciiCode));
        }// www. j a  v a 2 s.c  o m

        return sb.toString();
    }
}

Related

  1. Ascii2Hex(int len, byte data_in[], byte data_out[])
  2. asciiToHex(byte[] src, int len, int padding)
  3. ASCIIToHex(int args, int len)
  4. asciiToHex(String ascii)
  5. asciiToHex(String ascii)
  6. asciiToHex(String asciiValue)
  7. asciiToHexStr(String src)