本文整理了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
[英]Converts a signed byte into an unsigned integer representation (e.g., -1 becomes 255).
[中]将有符号字节转换为无符号整数表示(例如,-1变为255)。
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Populate data from this array as if it was in local file data.
*
* @param data an array of bytes
* @param offset the start offset
* @param length the number of bytes in the array from offset
* @throws java.util.zip.ZipException on error
*/
@Override
public void parseFromLocalFileData(
final byte[] data, int offset, final int length
) throws ZipException {
reset();
this.version = signedByteToUnsignedInt(data[offset++]);
final int uidSize = signedByteToUnsignedInt(data[offset++]);
final byte[] uidBytes = new byte[uidSize];
System.arraycopy(data, offset, uidBytes, 0, uidSize);
offset += uidSize;
this.uid = new BigInteger(1, reverse(uidBytes)); // sign-bit forced positive
final int gidSize = signedByteToUnsignedInt(data[offset++]);
final byte[] gidBytes = new byte[gidSize];
System.arraycopy(data, offset, gidBytes, 0, gidSize);
this.gid = new BigInteger(1, reverse(gidBytes)); // sign-bit forced positive
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Populate data from this array as if it was in local file data.
*
* @param data an array of bytes
* @param offset the start offset
* @param length the number of bytes in the array from offset
* @throws java.util.zip.ZipException on error
*/
@Override
public void parseFromLocalFileData(
final byte[] data, int offset, final int length
) throws ZipException {
reset();
this.version = signedByteToUnsignedInt(data[offset++]);
final int uidSize = signedByteToUnsignedInt(data[offset++]);
final byte[] uidBytes = new byte[uidSize];
System.arraycopy(data, offset, uidBytes, 0, uidSize);
offset += uidSize;
this.uid = new BigInteger(1, reverse(uidBytes)); // sign-bit forced positive
final int gidSize = signedByteToUnsignedInt(data[offset++]);
final byte[] gidBytes = new byte[gidSize];
System.arraycopy(data, offset, gidBytes, 0, gidSize);
this.gid = new BigInteger(1, reverse(gidBytes)); // sign-bit forced positive
}
内容来源于网络,如有侵权,请联系作者删除!