List of usage examples for java.lang Byte parseByte
public static byte parseByte(String s, int radix) throws NumberFormatException
From source file:net.jradius.client.gui.JRadiusSimulator.java
public byte[] toBinArray(String hexStr) { hexStr = hexStr.replace("0x", ""); byte bArray[] = new byte[hexStr.length() / 2]; for (int i = 0; i < (hexStr.length() / 2); i++) { byte firstNibble = Byte.parseByte(hexStr.substring(2 * i, 2 * i + 1), 16); byte secondNibble = Byte.parseByte(hexStr.substring(2 * i + 1, 2 * i + 2), 16); int finalByte = (secondNibble) | (firstNibble << 4); bArray[i] = (byte) finalByte; }//from w w w . ja v a 2 s . c o m return bArray; }