Java Hex Convert To fromHex(String src)

Here you can find the source of fromHex(String src)

Description

from Hex

License

Open Source License

Declaration

public static byte[] fromHex(String src) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] fromHex(String src) {
        String[] hex = src.split(" ");
        byte[] b = new byte[hex.length];
        for (int i = 0; i < hex.length; i++) {
            b[i] = (byte) (Integer.parseInt(hex[i], 16) & 0xff);
        }//  ww w .  ja  va 2s . c om
        return b;
    }

    public static String fromHex(String hexString, String charset) {
        try {
            byte[] b = fromHex(hexString);
            if (charset == null) {
                return new String(b);
            }
            return new String(b, charset);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. fromHex(String s)
  2. fromHex(String s)
  3. fromHex(String s)
  4. fromHex(String s)
  5. fromHex(String s, boolean hexIsDefault)
  6. fromHex(String str)
  7. fromHex(String str)
  8. fromHex(String string)
  9. fromHex(String text)