org.apache.commons.compress.archivers.zip.ZipUtil.signedByteToUnsignedInt()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.apache.commons.compress.archivers.zip.ZipUtil.signedByteToUnsignedInt()方法的一些代码示例,展示了ZipUtil.signedByteToUnsignedInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.signedByteToUnsignedInt()方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipUtil
类名称:ZipUtil
方法名:signedByteToUnsignedInt

ZipUtil.signedByteToUnsignedInt介绍

[英]Converts a signed byte into an unsigned integer representation (e.g., -1 becomes 255).
[中]将有符号字节转换为无符号整数表示(例如,-1变为255)。

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

  1. /**
  2. * Populate data from this array as if it was in local file data.
  3. *
  4. * @param data an array of bytes
  5. * @param offset the start offset
  6. * @param length the number of bytes in the array from offset
  7. * @throws java.util.zip.ZipException on error
  8. */
  9. @Override
  10. public void parseFromLocalFileData(
  11. final byte[] data, int offset, final int length
  12. ) throws ZipException {
  13. reset();
  14. this.version = signedByteToUnsignedInt(data[offset++]);
  15. final int uidSize = signedByteToUnsignedInt(data[offset++]);
  16. final byte[] uidBytes = new byte[uidSize];
  17. System.arraycopy(data, offset, uidBytes, 0, uidSize);
  18. offset += uidSize;
  19. this.uid = new BigInteger(1, reverse(uidBytes)); // sign-bit forced positive
  20. final int gidSize = signedByteToUnsignedInt(data[offset++]);
  21. final byte[] gidBytes = new byte[gidSize];
  22. System.arraycopy(data, offset, gidBytes, 0, gidSize);
  23. this.gid = new BigInteger(1, reverse(gidBytes)); // sign-bit forced positive
  24. }

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

  1. /**
  2. * Populate data from this array as if it was in local file data.
  3. *
  4. * @param data an array of bytes
  5. * @param offset the start offset
  6. * @param length the number of bytes in the array from offset
  7. * @throws java.util.zip.ZipException on error
  8. */
  9. @Override
  10. public void parseFromLocalFileData(
  11. final byte[] data, int offset, final int length
  12. ) throws ZipException {
  13. reset();
  14. this.version = signedByteToUnsignedInt(data[offset++]);
  15. final int uidSize = signedByteToUnsignedInt(data[offset++]);
  16. final byte[] uidBytes = new byte[uidSize];
  17. System.arraycopy(data, offset, uidBytes, 0, uidSize);
  18. offset += uidSize;
  19. this.uid = new BigInteger(1, reverse(uidBytes)); // sign-bit forced positive
  20. final int gidSize = signedByteToUnsignedInt(data[offset++]);
  21. final byte[] gidBytes = new byte[gidSize];
  22. System.arraycopy(data, offset, gidBytes, 0, gidSize);
  23. this.gid = new BigInteger(1, reverse(gidBytes)); // sign-bit forced positive
  24. }

相关文章