buf = new byte[length];
int numRead;
long numSkipped;
numSkipped = in.skip(offset);
if (numSkipped != offset) {
throw new ProductException("Was not able to skip: [" + offset
+ "] bytes into product: num actually skipped: [" + numSkipped
+ "]");
}
numRead = in.read(buf, 0, length);
if (numRead != length) {
throw new ProductException("Was not able to read: [" + length
+ "] bytes from product: num actually read: [" + numRead + "]");
}
} catch (IOException e) {
e.printStackTrace();
throw new ProductException("IO exception retrieving chunk of product: ["
+ filepath + "]: Message: " + e.getMessage());
} finally {
if (in != null) {
try {
in.close();