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

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

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

ZipEncoding.encode介绍

[英]Encode a filename or a comment to a byte array suitable for storing it to a serialized zip entry.

Examples for CP 437 (in pseudo-notation, right hand side is C-style notation):

encode("\u20AC_for_Dollar.txt") = "%U20AC_for_Dollar.txt" 
encode("\u00D6lf\u00E4sser.txt") = "\231lf\204sser.txt"

[中]将文件名或注释编码为适合将其存储到序列化zip条目的字节数组。
CP 437的示例(在伪符号中,右侧是C型符号):

encode("\u20AC_for_Dollar.txt") = "%U20AC_for_Dollar.txt" 
encode("\u00D6lf\u00E4sser.txt") = "\231lf\204sser.txt"

代码示例

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

/**
 * Encodes the given string using the configured encoding.
 *
 * @param str the String to write
 * @throws IOException if the string couldn't be written
 * @return result of encoding the string
 */
private byte[] encode(final String str) throws IOException {
  final ByteBuffer buf = zipEncoding.encode(str);
  final int len = buf.limit() - buf.position();
  return Arrays.copyOfRange(buf.array(), buf.arrayOffset(), buf.arrayOffset() + len);
}

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

throws IOException {
int len = name.length();
ByteBuffer b = encoding.encode(name);
while (b.limit() > length && len > 0) {
  b = encoding.encode(name.substring(0, --len));

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

private ByteBuffer getName(final ZipArchiveEntry ze) throws IOException {
  return getEntryEncoding(ze).encode(ze.getName());
}

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

final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
ze.addExtraField(new UnicodeCommentExtraField(comm,
                       commentB.array(),

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

final String paxHeaderName, final byte linkType, final String fieldName)
throws IOException {
final ByteBuffer encodedName = zipEncoding.encode(name);
final int len = encodedName.limit() - encodedName.position();
if (len >= TarConstants.NAMELEN) {

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

final ByteBuffer data = this.zipEncoding.encode(comment);
final int dataLen = data.limit() - data.position();
writeCounted(ZipShort.getBytes(dataLen));

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

final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
final int nameLen = name.limit() - name.position();
final int commentLen = commentB.limit() - commentB.position();

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

private byte[] encodeArchiveEntry( String payload, String encoding )
  throws IOException
{
  ZipEncoding enc = ZipEncodingHelper.getZipEncoding( encoding );
  ByteBuffer encodedPayloadByteBuffer = enc.encode( payload );
  byte[] encodedPayloadBytes = new byte[encodedPayloadByteBuffer.limit()];
  encodedPayloadByteBuffer.get( encodedPayloadBytes );
  return encodedPayloadBytes;
}

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

/**
 * Writes an ASCII string to the stream followed by \0
 * @param str the String to write
 * @throws IOException if the string couldn't be written
 */
private void writeCString(final String str) throws IOException {
  final ByteBuffer buf = zipEncoding.encode(str);
  final int len = buf.limit() - buf.position();
  out.write(buf.array(), buf.arrayOffset(), len);
  out.write('\0');
  count(len + 1);
}

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

throws IOException {
int len = name.length();
ByteBuffer b = encoding.encode(name);
while (b.limit() > length && len > 0) {
  b = encoding.encode(name.substring(0, --len));

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

private ByteBuffer getName(final ZipArchiveEntry ze) throws IOException {
  return getEntryEncoding(ze).encode(ze.getName());
}

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

final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
ze.addExtraField(new UnicodeCommentExtraField(comm,
                       commentB.array(),

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

final String paxHeaderName, final byte linkType, final String fieldName)
throws IOException {
final ByteBuffer encodedName = zipEncoding.encode(name);
final int len = encodedName.limit() - encodedName.position();
if (len >= TarConstants.NAMELEN) {

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

final ByteBuffer data = this.zipEncoding.encode(comment);
final int dataLen = data.limit() - data.position();
writeCounted(ZipShort.getBytes(dataLen));

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

final ByteBuffer commentB = getEntryEncoding(ze).encode(comm);
final int nameLen = name.limit() - name.position();
final int commentLen = commentB.limit() - commentB.position();

相关文章