在Java if语句中一起添加变量

时间:2017-12-04 17:38:38

标签: java

我有一个变量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

有关如何使这项工作的想法吗?

0 个答案:

没有答案