EbtsUtils { public static int byteArrayToInt(final byte[] bytes) { if (bytes.length == 4) { return Ints.fromByteArray(bytes); } else if (bytes.length == 2) { return Shorts.fromByteArray(bytes); } else if (bytes.length == 1) { return bytes[0] & 0xff; } else { throw new InputMismatchException("invalid data length of "+bytes.length); } } private  EbtsUtils(); static Set<Integer> getBinaryHeaderTypes(); static Set<Integer> getGenericRecordTypes(); static int tagToFieldNumber(final String tag); static int tagToRecordNumber(final String tag); static int[] splitTag(final String tag); static String fieldNumberToMnemonic(final int recordType, final int fieldNumber); static String fieldTagToMnemonic(final String tag); static int fieldMnemonicToNumber(final int recordType, final String fieldIdentifier); static List<String> convertOccurrenceList(final List<Occurrence> occurrences); static List<Occurrence> convertStringList(final List<String> strings); static List<Occurrence> convertStringList(final List<String> strings, final int limit); static List<SubField> convertStringListToSubFields(final List<String> strings); static int byteArrayToInt(final byte[] bytes); static String getMimeExtension(final byte[] data);  }
@Test public void testByteArrayToInt() throws Exception { byte[] data = new byte[4]; data[0] = 0x00; data[1] = 0x00; data[2] = (byte) 0x98; data[3] = (byte) 0xF2; int val = EbtsUtils.byteArrayToInt(data); assertEquals(39154,val); log.debug("{}",val); data = new byte[1]; data[0] = (byte) 0xFF; val = EbtsUtils.byteArrayToInt(data); log.debug("{}",val); data = new byte[2]; data[0] = (byte) 0xFF; data[1] = (byte) 0xFF; val = EbtsUtils.byteArrayToInt(data); log.debug("{}",val); }