Java Hex Convert To fromHex(String hex)

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

Description

from Hex

License

Apache License

Declaration

public static byte[] fromHex(String hex) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static byte[] fromHex(String hex) {
        if (hex != null && hex.length() > 1) {
            try {
                byte bytes[] = new byte[hex.length() / 2];
                for (int i = 0; i < bytes.length; i++) {
                    bytes[i] = (byte) Integer.parseInt(hex.substring(i << 1, (i << 1) + 2), 16);
                }/*from  ww w .j  a  va2s  .  co  m*/
                return bytes;
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }

        return null;
    }
}

Related

  1. fromHex(String hex)
  2. fromHex(String hex)
  3. fromHex(String hex)
  4. fromHex(String hex)
  5. fromHex(String hex)
  6. fromHex(String hex)
  7. fromHex(String hex)
  8. fromHex(String hex)
  9. fromHex(String hex)