我有一个变量HEADER_DIFF
。它使用:
public static final long HEADER_DIFF = 76;
然后我接到了这个电话:
private static byte[] copyToByteArray(final InputStream is,
final int recordLength, final boolean enforceLength)
throws IOException {
BoundedInputStream bis = new BoundedInputStream(is, recordLength);
byte[] rawContents = IOUtils.toByteArray(bis);
if (!(rawContents.length == recordLength + HEADER_DIFF
|| rawContents.length == recordLength)) {
LOG.error("Read " + rawContents.length + " bytes but expected "
+ recordLength + " bytes. Continuing...");
}
return rawContents;
}
问题是,当我们执行if语句时,recordLength
没有添加到HEADER_DIFF
。实际上,如果我在LOG
决定打印recordLength + HEADER_DIFF
,我只需获得recordLength
。
有关如何使这项工作的想法吗?