class 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;
    }

}

class HexStringTest  {

    @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) {
            // do nothing
        }
    }

}