@Test public void testFromHexStringError() { String invalidStr = "00:00:00:00:00:00:ffff"; try { HexString.fromHexString(invalidStr); fail("HexString.fromHexString() should have thrown a NumberFormatException"); } catch (NumberFormatException expected) { } }
public static byte[] fromHexString(String values) throws NumberFormatException { String[] octets = values.split(":"); byte[] ret = new byte[octets.length]; for(int i = 0; i < octets.length; i++) { if (octets[i].length() > 2) throw new NumberFormatException("Invalid octet length"); ret[i] = Integer.valueOf(octets[i], 16).byteValue(); } return ret; }
HexString { public static byte[] fromHexString(String values) throws NumberFormatException { String[] octets = values.split(":"); byte[] ret = new byte[octets.length]; for(int i = 0; i < octets.length; i++) { if (octets[i].length() > 2) throw new NumberFormatException("Invalid octet length"); ret[i] = Integer.valueOf(octets[i], 16).byteValue(); } return ret; } }
HexString { public static byte[] fromHexString(String values) throws NumberFormatException { String[] octets = values.split(":"); byte[] ret = new byte[octets.length]; for(int i = 0; i < octets.length; i++) { if (octets[i].length() > 2) throw new NumberFormatException("Invalid octet length"); ret[i] = Integer.valueOf(octets[i], 16).byteValue(); } return ret; }  }
HexString { public static byte[] fromHexString(String values) throws NumberFormatException { String[] octets = values.split(":"); byte[] ret = new byte[octets.length]; for(int i = 0; i < octets.length; i++) { if (octets[i].length() > 2) throw new NumberFormatException("Invalid octet length"); ret[i] = Integer.valueOf(octets[i], 16).byteValue(); } return ret; }  static String toHexString(byte[] bytes); static String toHexString(long val, int padTo); static String toHexString(long val); static byte[] fromHexString(String values); static long toLong(String values); }
HexString { public static byte[] fromHexString(String values) throws NumberFormatException { String[] octets = values.split(":"); byte[] ret = new byte[octets.length]; for(int i = 0; i < octets.length; i++) { if (octets[i].length() > 2) throw new NumberFormatException("Invalid octet length"); ret[i] = Integer.valueOf(octets[i], 16).byteValue(); } return ret; }  static String toHexString(byte[] bytes); static String toHexString(long val, int padTo); static String toHexString(long val); static byte[] fromHexString(String values); static long toLong(String values);  }