Android String to Hex String Convert hexStr2Str(String hexStr)

Here you can find the source of hexStr2Str(String hexStr)

Description

hex Str Str

Declaration

public static String hexStr2Str(String hexStr) 

Method Source Code

//package com.java2s;

public class Main {

    public static String hexStr2Str(String hexStr) {
        String str = "0123456789ABCDEF";
        char[] hexs = hexStr.toCharArray();
        byte[] bytes = new byte[hexStr.length() / 2];
        int n;//from   w ww .j av a  2s  .  co  m

        for (int i = 0; i < bytes.length; i++) {
            n = str.indexOf(hexs[2 * i]) * 16;
            n += str.indexOf(hexs[2 * i + 1]);
            bytes[i] = (byte) (n & 0xff);
        }
        return new String(bytes);
    }
}

Related

  1. toHex(String txt)
  2. toHex(byte[] buf)
  3. toHexString(String str)
  4. hexStringToCommonString(String hexString)
  5. toHex(String txt)
  6. toHex(String txt)
  7. parseHexStr2Byte(String hexStr)