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

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

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

ZipUtil.getUnicodeStringIfOriginalMatches介绍

[英]If the stored CRC matches the one of the given name, return the Unicode name of the given field.

If the field is null or the CRCs don't match, return null instead.
[中]如果存储的CRC与给定名称中的一个匹配,则返回给定字段的Unicode名称。
如果字段为null或CRC不匹配,则返回null。

代码示例

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

/**
 * If the entry has Unicode*ExtraFields and the CRCs of the
 * names/comments match those of the extra fields, transfer the
 * known Unicode values from the extra field.
 */
static void setNameAndCommentFromExtraFields(final ZipArchiveEntry ze,
                       final byte[] originalNameBytes,
                       final byte[] commentBytes) {
  final UnicodePathExtraField name = (UnicodePathExtraField)
    ze.getExtraField(UnicodePathExtraField.UPATH_ID);
  final String newName = getUnicodeStringIfOriginalMatches(name,
                            originalNameBytes);
  if (newName != null) {
    ze.setName(newName);
    ze.setNameSource(ZipArchiveEntry.NameSource.UNICODE_EXTRA_FIELD);
  }
  if (commentBytes != null && commentBytes.length > 0) {
    final UnicodeCommentExtraField cmt = (UnicodeCommentExtraField)
      ze.getExtraField(UnicodeCommentExtraField.UCOM_ID);
    final String newComment =
      getUnicodeStringIfOriginalMatches(cmt, commentBytes);
    if (newComment != null) {
      ze.setComment(newComment);
      ze.setCommentSource(ZipArchiveEntry.CommentSource.UNICODE_EXTRA_FIELD);
    }
  }
}

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

/**
 * If the entry has Unicode*ExtraFields and the CRCs of the
 * names/comments match those of the extra fields, transfer the
 * known Unicode values from the extra field.
 */
static void setNameAndCommentFromExtraFields(final ZipArchiveEntry ze,
                       final byte[] originalNameBytes,
                       final byte[] commentBytes) {
  final UnicodePathExtraField name = (UnicodePathExtraField)
    ze.getExtraField(UnicodePathExtraField.UPATH_ID);
  final String newName = getUnicodeStringIfOriginalMatches(name,
                            originalNameBytes);
  if (newName != null) {
    ze.setName(newName);
    ze.setNameSource(ZipArchiveEntry.NameSource.UNICODE_EXTRA_FIELD);
  }
  if (commentBytes != null && commentBytes.length > 0) {
    final UnicodeCommentExtraField cmt = (UnicodeCommentExtraField)
      ze.getExtraField(UnicodeCommentExtraField.UCOM_ID);
    final String newComment =
      getUnicodeStringIfOriginalMatches(cmt, commentBytes);
    if (newComment != null) {
      ze.setComment(newComment);
      ze.setCommentSource(ZipArchiveEntry.CommentSource.UNICODE_EXTRA_FIELD);
    }
  }
}

相关文章