@Test public void testHex2byteThrowsArrayIndexOutOfBoundsException() throws Throwable { byte[] b = new byte[3]; try { ISOUtil.hex2byte(b, 0, 100); fail("Expected ArrayIndexOutOfBoundsException to be thrown"); } catch (ArrayIndexOutOfBoundsException ex) { if (isJavaVersionAtMost(JAVA_10)) { assertEquals("3", ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Index 3 out of bounds for length 3", ex.getMessage(), "ex.getMessage()"); } } }
public static byte[] hex2byte (byte[] b, int offset, int len) { byte[] d = new byte[len]; for (int i=0; i<len*2; i++) { int shift = i%2 == 1 ? 0 : 4; d[i>>1] |= Character.digit((char) b[offset+i], 16) << shift; } return d; }
ISOUtil { public static byte[] hex2byte (byte[] b, int offset, int len) { byte[] d = new byte[len]; for (int i=0; i<len*2; i++) { int shift = i%2 == 1 ? 0 : 4; d[i>>1] |= Character.digit((char) b[offset+i], 16) << shift; } return d; } }
ISOUtil { public static byte[] hex2byte (byte[] b, int offset, int len) { byte[] d = new byte[len]; for (int i=0; i<len*2; i++) { int shift = i%2 == 1 ? 0 : 4; d[i>>1] |= Character.digit((char) b[offset+i], 16) << shift; } return d; } ISOUtil(); }
ISOUtil { public static byte[] hex2byte (byte[] b, int offset, int len) { byte[] d = new byte[len]; for (int i=0; i<len*2; i++) { int shift = i%2 == 1 ? 0 : 4; d[i>>1] |= Character.digit((char) b[offset+i], 16) << shift; } return d; } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2hex(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset,
                        int len, boolean padLeft); static String hex2str(byte[] b, int offset,
                                 int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String stripUnicode(String s); static String normalize(String s); static String protect(String s, char mask); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2,
            int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad( String s ); static String blankUnPad( String s ); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero( String s ); static boolean isBlank( String s ); static boolean isAlphaNumeric( String s ); static boolean isNumeric( String s, int radix ); static byte[] bitSet2extendedByte( BitSet b ); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s,int n); static String takeFirstN(String s,int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String... ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String readableFileSize(long size); static String hexDump(byte[] array, int offset, int length, Charset charSet); static byte[] decodeHexDump(String s); }
ISOUtil { public static byte[] hex2byte (byte[] b, int offset, int len) { byte[] d = new byte[len]; for (int i=0; i<len*2; i++) { int shift = i%2 == 1 ? 0 : 4; d[i>>1] |= Character.digit((char) b[offset+i], 16) << shift; } return d; } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2hex(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset,
                        int len, boolean padLeft); static String hex2str(byte[] b, int offset,
                                 int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String stripUnicode(String s); static String normalize(String s); static String protect(String s, char mask); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2,
            int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad( String s ); static String blankUnPad( String s ); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero( String s ); static boolean isBlank( String s ); static boolean isAlphaNumeric( String s ); static boolean isNumeric( String s, int radix ); static byte[] bitSet2extendedByte( BitSet b ); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s,int n); static String takeFirstN(String s,int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String... ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String readableFileSize(long size); static String hexDump(byte[] array, int offset, int length, Charset charSet); static byte[] decodeHexDump(String s); static final String[] hexStrings; static final String ENCODING; static final Pattern unicodePattern; static final Charset CHARSET; static final Charset EBCDIC; static final byte STX; static final byte FS; static final byte US; static final byte RS; static final byte GS; static final byte ETX; }