List of usage examples for java.nio ByteBuffer getInt
public abstract int getInt();
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleProtocol.java
private GBDeviceEvent[] decodeAction(ByteBuffer buf) { buf.order(ByteOrder.LITTLE_ENDIAN); byte command = buf.get(); if (command == NOTIFICATIONACTION_INVOKE) { int id;/*from w w w .ja v a 2 s .c o m*/ UUID uuid = new UUID(0, 0); if (mFwMajor >= 3) { uuid = getUUID(buf); id = (int) (uuid.getLeastSignificantBits() & 0xffffffffL); } else { id = buf.getInt(); } byte action = buf.get(); if (action >= 0x00 && action <= 0x05) { GBDeviceEventNotificationControl devEvtNotificationControl = new GBDeviceEventNotificationControl(); devEvtNotificationControl.handle = id; String caption = "undefined"; int icon_id = 1; boolean needsAck2x = true; switch (action) { case 0x01: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.OPEN; caption = "Opened"; icon_id = PebbleIconID.DURING_PHONE_CALL; break; case 0x02: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS; caption = "Dismissed"; icon_id = PebbleIconID.RESULT_DISMISSED; needsAck2x = false; break; case 0x03: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS_ALL; caption = "All dismissed"; icon_id = PebbleIconID.RESULT_DISMISSED; needsAck2x = false; break; case 0x04: devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.MUTE; caption = "Muted"; icon_id = PebbleIconID.RESULT_MUTE; break; case 0x05: case 0x00: boolean failed = true; byte attribute_count = buf.get(); if (attribute_count > 0) { byte attribute = buf.get(); if (attribute == 0x01) { // reply string is in attribute 0x01 short length = buf.getShort(); if (length > 64) length = 64; byte[] reply = new byte[length]; buf.get(reply); devEvtNotificationControl.phoneNumber = null; if (buf.remaining() > 1 && buf.get() == 0x0c) { short phoneNumberLength = buf.getShort(); byte[] phoneNumberBytes = new byte[phoneNumberLength]; buf.get(phoneNumberBytes); devEvtNotificationControl.phoneNumber = new String(phoneNumberBytes); } devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; devEvtNotificationControl.reply = new String(reply); caption = "SENT"; icon_id = PebbleIconID.RESULT_SENT; failed = false; } } if (failed) { caption = "FAILED"; icon_id = PebbleIconID.RESULT_FAILED; devEvtNotificationControl = null; // error } break; } GBDeviceEventSendBytes sendBytesAck = null; if (mFwMajor >= 3 || needsAck2x) { sendBytesAck = new GBDeviceEventSendBytes(); if (mFwMajor >= 3) { sendBytesAck.encodedBytes = encodeActionResponse(uuid, icon_id, caption); } else { sendBytesAck.encodedBytes = encodeActionResponse2x(id, action, 6, caption); } } return new GBDeviceEvent[] { sendBytesAck, devEvtNotificationControl }; } LOG.info("unexpected action: " + action); } return null; }
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleProtocol.java
private GBDeviceEvent[] decodeDatalog(ByteBuffer buf, short length) { boolean ack = true; byte command = buf.get(); byte id = buf.get(); GBDeviceEventDataLogging devEvtDataLogging = null; switch (command) { case DATALOG_TIMEOUT: LOG.info("DATALOG TIMEOUT. id=" + (id & 0xff) + " - ignoring"); return null; case DATALOG_SENDDATA: buf.order(ByteOrder.LITTLE_ENDIAN); int items_left = buf.getInt(); int crc = buf.getInt(); DatalogSession datalogSession = mDatalogSessions.get(id); LOG.info("DATALOG SENDDATA. id=" + (id & 0xff) + ", items_left=" + items_left + ", total length=" + (length - 10));//from w w w . j a va2 s.c o m if (datalogSession != null) { LOG.info("DATALOG UUID=" + datalogSession.uuid + ", tag=" + datalogSession.tag + datalogSession.getTaginfo() + ", itemSize=" + datalogSession.itemSize + ", itemType=" + datalogSession.itemType); if (!datalogSession.uuid.equals(UUID_ZERO) && datalogSession.getClass().equals(DatalogSession.class) && mEnablePebbleKit) { devEvtDataLogging = datalogSession.handleMessageForPebbleKit(buf, length - 10); if (devEvtDataLogging == null) { ack = false; } } else { ack = datalogSession.handleMessage(buf, length - 10); } } break; case DATALOG_OPENSESSION: UUID uuid = getUUID(buf); buf.order(ByteOrder.LITTLE_ENDIAN); int timestamp = buf.getInt(); int log_tag = buf.getInt(); byte item_type = buf.get(); short item_size = buf.getShort(); LOG.info("DATALOG OPENSESSION. id=" + (id & 0xff) + ", App UUID=" + uuid.toString() + ", log_tag=" + log_tag + ", item_type=" + item_type + ", itemSize=" + item_size); if (!mDatalogSessions.containsKey(id)) { if (uuid.equals(UUID_ZERO) && log_tag == 81) { mDatalogSessions.put(id, new DatalogSessionHealthSteps(id, uuid, timestamp, log_tag, item_type, item_size, getDevice())); } else if (uuid.equals(UUID_ZERO) && log_tag == 83) { mDatalogSessions.put(id, new DatalogSessionHealthSleep(id, uuid, timestamp, log_tag, item_type, item_size, getDevice())); } else if (uuid.equals(UUID_ZERO) && log_tag == 84) { mDatalogSessions.put(id, new DatalogSessionHealthOverlayData(id, uuid, timestamp, log_tag, item_type, item_size, getDevice())); } else if (uuid.equals(UUID_ZERO) && log_tag == 85) { mDatalogSessions.put(id, new DatalogSessionHealthHR(id, uuid, timestamp, log_tag, item_type, item_size, getDevice())); } else { mDatalogSessions.put(id, new DatalogSession(id, uuid, timestamp, log_tag, item_type, item_size)); } } break; case DATALOG_CLOSE: LOG.info("DATALOG_CLOSE. id=" + (id & 0xff)); datalogSession = mDatalogSessions.get(id); if (datalogSession != null) { if (!datalogSession.uuid.equals(UUID_ZERO) && datalogSession.getClass().equals(DatalogSession.class) && mEnablePebbleKit) { GBDeviceEventDataLogging dataLogging = new GBDeviceEventDataLogging(); dataLogging.command = GBDeviceEventDataLogging.COMMAND_FINISH_SESSION; dataLogging.appUUID = datalogSession.uuid; dataLogging.tag = datalogSession.tag; devEvtDataLogging = dataLogging; } mDatalogSessions.remove(id); } break; default: LOG.info("unknown DATALOG command: " + (command & 0xff)); break; } GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes(); if (ack) { LOG.info("sending ACK (0x85)"); sendBytes.encodedBytes = encodeDatalog(id, DATALOG_ACK); } else { LOG.info("sending NACK (0x86)"); sendBytes.encodedBytes = encodeDatalog(id, DATALOG_NACK); } // append ack/nack return new GBDeviceEvent[] { devEvtDataLogging, sendBytes }; }
From source file:srebrinb.compress.sevenzip.SevenZFile.java
private void readSubStreamsInfo(final ByteBuffer header, final Archive archive) throws IOException { for (final Folder folder : archive.folders) { folder.numUnpackSubStreams = 1;// ww w.ja v a 2s. c om } int totalUnpackStreams = archive.folders.length; int nid = getUnsignedByte(header); if (nid == NID.kNumUnpackStream) { totalUnpackStreams = 0; for (final Folder folder : archive.folders) { final long numStreams = readUint64(header); folder.numUnpackSubStreams = (int) numStreams; totalUnpackStreams += numStreams; } nid = getUnsignedByte(header); } final SubStreamsInfo subStreamsInfo = new SubStreamsInfo(); subStreamsInfo.unpackSizes = new long[totalUnpackStreams]; subStreamsInfo.hasCrc = new BitSet(totalUnpackStreams); subStreamsInfo.crcs = new long[totalUnpackStreams]; int nextUnpackStream = 0; for (final Folder folder : archive.folders) { if (folder.numUnpackSubStreams == 0) { continue; } long sum = 0; if (nid == NID.kSize) { for (int i = 0; i < folder.numUnpackSubStreams - 1; i++) { final long size = readUint64(header); subStreamsInfo.unpackSizes[nextUnpackStream++] = size; sum += size; } } subStreamsInfo.unpackSizes[nextUnpackStream++] = folder.getUnpackSize() - sum; } if (nid == NID.kSize) { nid = getUnsignedByte(header); } int numDigests = 0; for (final Folder folder : archive.folders) { if (folder.numUnpackSubStreams != 1 || !folder.hasCrc) { numDigests += folder.numUnpackSubStreams; } } if (nid == NID.kCRC) { final BitSet hasMissingCrc = readAllOrBits(header, numDigests); final long[] missingCrcs = new long[numDigests]; for (int i = 0; i < numDigests; i++) { if (hasMissingCrc.get(i)) { missingCrcs[i] = 0xffffFFFFL & header.getInt(); } } int nextCrc = 0; int nextMissingCrc = 0; for (final Folder folder : archive.folders) { if (folder.numUnpackSubStreams == 1 && folder.hasCrc) { subStreamsInfo.hasCrc.set(nextCrc, true); subStreamsInfo.crcs[nextCrc] = folder.crc; ++nextCrc; } else { for (int i = 0; i < folder.numUnpackSubStreams; i++) { subStreamsInfo.hasCrc.set(nextCrc, hasMissingCrc.get(nextMissingCrc)); subStreamsInfo.crcs[nextCrc] = missingCrcs[nextMissingCrc]; ++nextCrc; ++nextMissingCrc; } } } nid = getUnsignedByte(header); } if (nid != NID.kEnd) { throw new IOException("Badly terminated SubStreamsInfo"); } archive.subStreamsInfo = subStreamsInfo; }
From source file:com.healthmarketscience.jackcess.IndexData.java
/** * Read the rest of the index info from a tableBuffer * @param tableBuffer table definition buffer to read from initial info * @param availableColumns Columns that this index may use *//*from w ww . j a va 2s.c o m*/ public void read(ByteBuffer tableBuffer, List<Column> availableColumns) throws IOException { ByteUtil.forward(tableBuffer, getFormat().SKIP_BEFORE_INDEX); //Forward past Unknown for (int i = 0; i < MAX_COLUMNS; i++) { short columnNumber = tableBuffer.getShort(); byte colFlags = tableBuffer.get(); if (columnNumber != COLUMN_UNUSED) { // find the desired column by column number (which is not necessarily // the same as the column index) Column idxCol = null; for (Column col : availableColumns) { if (col.getColumnNumber() == columnNumber) { idxCol = col; break; } } if (idxCol == null) { throw new IOException("Could not find column with number " + columnNumber + " for index"); } _columns.add(newColumnDescriptor(idxCol, colFlags)); } } int umapRowNum = tableBuffer.get(); int umapPageNum = ByteUtil.get3ByteInt(tableBuffer); _ownedPages = UsageMap.read(getTable().getDatabase(), umapPageNum, umapRowNum, false); _rootPageNumber = tableBuffer.getInt(); ByteUtil.forward(tableBuffer, getFormat().SKIP_BEFORE_INDEX_FLAGS); //Forward past Unknown _indexFlags = tableBuffer.get(); ByteUtil.forward(tableBuffer, getFormat().SKIP_AFTER_INDEX_FLAGS); //Forward past other stuff }
From source file:au.org.ala.layers.intersect.Grid.java
public float[] getGrid() { int maxArrayLength = Integer.MAX_VALUE - 10; if (grid_data != null) { return grid_data; }// w ww . j av a2 s .c o m Grid loadedAlready = getLoadedGrid(filename); if (loadedAlready != null && loadedAlready.grid_data != null) { return loadedAlready.grid_data; } int length = nrows * ncols; float[] ret = new float[length]; RandomAccessFile afile = null; File f2 = new File(filename + ".GRI"); try { //read of random access file can throw an exception if (!f2.exists()) { afile = new RandomAccessFile(filename + ".gri", "r"); } else { afile = new RandomAccessFile(filename + ".GRI", "r"); } byte[] b = new byte[(int) Math.min(afile.length(), maxArrayLength)]; int i = 0; int max = 0; int len; while ((len = afile.read(b)) > 0) { ByteBuffer bb = ByteBuffer.wrap(b); if (byteorderLSB) { bb.order(ByteOrder.LITTLE_ENDIAN); } if (datatype.equalsIgnoreCase("UBYTE")) { max += len; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.get(); if (ret[i] < 0) { ret[i] += 256; } } } else if (datatype.equalsIgnoreCase("BYTE")) { max += len; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.get(); } } else if (datatype.equalsIgnoreCase("SHORT")) { max += len / 2; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.getShort(); } } else if (datatype.equalsIgnoreCase("INT")) { max += len / 4; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.getInt(); } } else if (datatype.equalsIgnoreCase("LONG")) { max += len / 8; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.getLong(); } } else if (datatype.equalsIgnoreCase("FLOAT")) { max += len / 4; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = bb.getFloat(); } } else if (datatype.equalsIgnoreCase("DOUBLE")) { max += len / 8; max = Math.min(max, ret.length); for (; i < max; i++) { ret[i] = (float) bb.getDouble(); } } else { // / should not happen; catch anyway... max += len / 4; for (; i < max; i++) { ret[i] = Float.NaN; } } } //replace not a number for (i = 0; i < length; i++) { if ((float) ret[i] == (float) nodatavalue) { ret[i] = Float.NaN; } else { ret[i] *= rescale; } } } catch (Exception e) { logger.error("An error has occurred - probably a file error", e); } finally { if (afile != null) { try { afile.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } } } grid_data = ret; return ret; }
From source file:com.healthmarketscience.jackcess.impl.IndexData.java
/** * Read the rest of the index info from a tableBuffer * @param tableBuffer table definition buffer to read from initial info * @param availableColumns Columns that this index may use *///from w w w .j a va 2 s.co m public void read(ByteBuffer tableBuffer, List<ColumnImpl> availableColumns) throws IOException { ByteUtil.forward(tableBuffer, getFormat().SKIP_BEFORE_INDEX); //Forward past Unknown for (int i = 0; i < MAX_COLUMNS; i++) { short columnNumber = tableBuffer.getShort(); byte colFlags = tableBuffer.get(); if (columnNumber != COLUMN_UNUSED) { // find the desired column by column number (which is not necessarily // the same as the column index) ColumnImpl idxCol = null; for (ColumnImpl col : availableColumns) { if (col.getColumnNumber() == columnNumber) { idxCol = col; break; } } if (idxCol == null) { throw new IOException("Could not find column with number " + columnNumber + " for index"); } _columns.add(newColumnDescriptor(idxCol, colFlags)); } } _ownedPages = UsageMap.read(getTable().getDatabase(), tableBuffer, false); _rootPageNumber = tableBuffer.getInt(); ByteUtil.forward(tableBuffer, getFormat().SKIP_BEFORE_INDEX_FLAGS); //Forward past Unknown _indexFlags = tableBuffer.get(); ByteUtil.forward(tableBuffer, getFormat().SKIP_AFTER_INDEX_FLAGS); //Forward past other stuff }
From source file:org.neo4j.io.pagecache.PageCacheTest.java
@Test(timeout = SHORT_TIMEOUT_MILLIS) public void writesOfDifferentUnitsMustHaveCorrectEndianess() throws Exception { getPageCache(fs, maxPages, pageCachePageSize, PageCacheTracer.NULL); PagedFile pagedFile = pageCache.map(file("a"), 20); try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK)) { assertTrue(cursor.next());/* w ww. ja v a 2s . c o m*/ byte[] data = { 42, 43, 44, 45, 46 }; cursor.putLong(41); // 0+8 = 8 cursor.putInt(41); // 8+4 = 12 cursor.putShort((short) 41); // 12+2 = 14 cursor.putByte((byte) 41); // 14+1 = 15 cursor.putBytes(data); // 15+5 = 20 } try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK)) { assertTrue(cursor.next()); long a = cursor.getLong(); // 8 int b = cursor.getInt(); // 12 short c = cursor.getShort();// 14 byte[] data = new byte[] { cursor.getByte(), // 15 cursor.getByte(), // 16 cursor.getByte(), // 17 cursor.getByte(), // 18 cursor.getByte(), // 19 cursor.getByte() // 20 }; cursor.setOffset(0); cursor.putLong(1 + a); cursor.putInt(1 + b); cursor.putShort((short) (1 + c)); for (byte d : data) { d++; cursor.putByte(d); } } pagedFile.close(); StoreChannel channel = fs.open(file("a"), "r"); ByteBuffer buf = ByteBuffer.allocate(20); channel.read(buf); buf.flip(); assertThat(buf.getLong(), is(42L)); assertThat(buf.getInt(), is(42)); assertThat(buf.getShort(), is((short) 42)); assertThat(buf.get(), is((byte) 42)); assertThat(buf.get(), is((byte) 43)); assertThat(buf.get(), is((byte) 44)); assertThat(buf.get(), is((byte) 45)); assertThat(buf.get(), is((byte) 46)); assertThat(buf.get(), is((byte) 47)); }
From source file:au.org.ala.layers.intersect.Grid.java
public void replaceValues(Map<Integer, Integer> translation) { long length = ((long) nrows) * ((long) ncols); Integer minv = null;/*from w w w.j av a 2 s . c o m*/ Integer maxv = null; for (Integer i : translation.values()) { if (minv == null || i < minv) minv = i; if (maxv == null || i > maxv) maxv = i; } RandomAccessFile afile = null; RandomAccessFile out = null; File f2 = new File(filename + ".GRI"); File newGrid = new File(filename + ".gri.new"); try { //read of random access file can throw an exception out = new RandomAccessFile(newGrid, "rw"); if (!f2.exists()) { afile = new RandomAccessFile(filename + ".gri", "r"); } else { afile = new RandomAccessFile(filename + ".GRI", "r"); } byte[] b = new byte[65536]; byte[] bout = new byte[65536]; long i = 0; long max = 0; long len; float v; float ndv = (float) nodatavalue; while ((len = afile.read(b)) > 0) { ByteBuffer bb = ByteBuffer.wrap(b); ByteBuffer bbout = ByteBuffer.wrap(bout); if (byteorderLSB) { bb.order(ByteOrder.LITTLE_ENDIAN); bbout.order(ByteOrder.LITTLE_ENDIAN); } if (datatype.equalsIgnoreCase("UBYTE")) { throw new Exception("UBYTE translation not supported"); } else if (datatype.equalsIgnoreCase("BYTE")) { throw new Exception("BYTE translation not supported"); } else if (datatype.equalsIgnoreCase("SHORT")) { max += len / 2; max = Math.min(max, length); for (; i < max; i++) { v = bb.getShort(); if (v != ndv && translation.get((int) (v * rescale)) == null) { v = v; } if (v != ndv && translation.get((int) (v * rescale)) != null) v = translation.get((int) (v * rescale)); bbout.putShort((short) v); } } else if (datatype.equalsIgnoreCase("INT")) { max += len / 4; max = Math.min(max, length); for (; i < max; i++) { v = bb.getInt(); if (v != ndv && translation.get((int) (v * rescale)) != null) v = translation.get((int) (v * rescale)); bbout.putInt((int) v); } } else if (datatype.equalsIgnoreCase("LONG")) { max += len / 8; max = Math.min(max, length); for (; i < max; i++) { v = bb.getLong(); if (v != ndv && translation.get((int) (v * rescale)) != null) v = translation.get((int) (v * rescale)); bbout.putLong((long) v); } } else if (datatype.equalsIgnoreCase("FLOAT")) { throw new Exception("FLOAT translation not supported"); } else if (datatype.equalsIgnoreCase("DOUBLE")) { throw new Exception("DOUBLE translation not supported"); } else { max += len / 4; for (; i < max; i++) { // should not happen; catch anyway... } } out.write(bout, 0, (int) len); } writeHeader(filename + ".new", xmin, ymin, xmin + xres * ncols, ymin + yres * nrows, xres, yres, nrows, ncols, minv, maxv, datatype, nodatavalue + ""); } catch (Exception e) { logger.error("An error has occurred getting grid class stats", e); } finally { if (afile != null) { try { afile.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } } if (out != null) { try { out.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } } } try { if (!new File(filename + ".gri.old").exists()) FileUtils.moveFile(new File(filename + ".gri"), new File(filename + ".gri.old")); if (!new File(filename + ".grd.old").exists()) FileUtils.moveFile(new File(filename + ".grd"), new File(filename + ".grd.old")); FileUtils.moveFile(new File(filename + ".gri.new"), new File(filename + ".gri")); FileUtils.moveFile(new File(filename + ".new.grd"), new File(filename + ".grd")); } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.sav.SAVFileReader.java
private int[] parseRT7SubTypefieldHeader(BufferedInputStream stream) throws IOException { int length_unit_length = 4; int length_number_of_units = 4; int storage_size = length_unit_length + length_number_of_units; int[] headerSection = new int[2]; byte[] byteStorage = new byte[storage_size]; try {/*from w w w . j av a 2s .co m*/ int nbytes = stream.read(byteStorage); // to-do check against nbytes //printHexDump(byteStorage, "RT7:storage"); ByteBuffer bb_data_type = ByteBuffer.wrap(byteStorage, 0, length_unit_length); if (isLittleEndian) { bb_data_type.order(ByteOrder.LITTLE_ENDIAN); } int unitLength = bb_data_type.getInt(); dbgLog.fine("parseRT7 SubTypefield: unitLength=" + unitLength); ByteBuffer bb_number_of_units = ByteBuffer.wrap(byteStorage, length_unit_length, length_number_of_units); if (isLittleEndian) { bb_number_of_units.order(ByteOrder.LITTLE_ENDIAN); } int numberOfUnits = bb_number_of_units.getInt(); dbgLog.fine("parseRT7 SubTypefield: numberOfUnits=" + numberOfUnits); headerSection[0] = unitLength; headerSection[1] = numberOfUnits; return headerSection; } catch (IOException ex) { throw ex; } }
From source file:edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.sav.SAVFileReader.java
private List<byte[]> getRT7SubTypefieldData(BufferedInputStream stream) throws IOException { int length_unit_length = 4; int length_number_of_units = 4; int storage_size = length_unit_length + length_number_of_units; List<byte[]> dataList = new ArrayList<byte[]>(); int[] headerSection = new int[2]; byte[] byteStorage = new byte[storage_size]; try {// w ww . j a v a 2 s .c om int nbytes = stream.read(byteStorage); // to-do check against nbytes //printHexDump(byteStorage, "RT7:storage"); ByteBuffer bb_data_type = ByteBuffer.wrap(byteStorage, 0, length_unit_length); if (isLittleEndian) { bb_data_type.order(ByteOrder.LITTLE_ENDIAN); } int unitLength = bb_data_type.getInt(); dbgLog.fine("parseRT7SubTypefield: unitLength=" + unitLength); ByteBuffer bb_number_of_units = ByteBuffer.wrap(byteStorage, length_unit_length, length_number_of_units); if (isLittleEndian) { bb_number_of_units.order(ByteOrder.LITTLE_ENDIAN); } int numberOfUnits = bb_number_of_units.getInt(); dbgLog.fine("parseRT7SubTypefield: numberOfUnits=" + numberOfUnits); headerSection[0] = unitLength; headerSection[1] = numberOfUnits; for (int i = 0; i < numberOfUnits; i++) { byte[] work = new byte[unitLength]; int nb = stream.read(work); dbgLog.finer(new String(Hex.encodeHex(work))); dataList.add(work); } } catch (IOException ex) { //ex.printStackTrace(); throw ex; } return dataList; }