gpt4 book ai didi

org.apache.tools.ant.types.resources.ZipResource类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:41:52 28 4
gpt4 key购买 nike

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

ZipResource介绍

[英]A Resource representation of an entry in a zipfile.
[中]zipfile中条目的资源表示形式。

代码示例

代码示例来源:origin: org.apache.ant/ant

/**
 * Retrieves extra fields.
 * @return an array of the extra fields
 * @since Ant 1.8.0
 */
public ZipExtraField[] getExtraFields() {
  if (isReference()) {
    return ((ZipResource) getCheckedRef()).getExtraFields();
  }
  checkEntry();
  if (extras == null) {
    return new ZipExtraField[0];
  }
  return extras;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * fetches information from the named entry inside the archive.
 */
protected void fetchEntry() {
  ZipFile z = null;
  try {
    z = new ZipFile(getZipfile(), getEncoding());
    setEntry(z.getEntry(getName()));
  } catch (IOException e) {
    log(e.getMessage(), Project.MSG_DEBUG);
    throw new BuildException(e);
  } finally {
    ZipFile.closeQuietly(z);
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Set the encoding to use with the zipfile.
 * @param enc the String encoding.
 */
public void setEncoding(String enc) {
  checkAttributesAllowed();
  encoding = enc;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Get the encoding to use with the zipfile.
 * @return String encoding.
 */
public String getEncoding() {
  return isReference()
    ? ((ZipResource) getCheckedRef()).getEncoding() : encoding;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Get an OutputStream for the Resource.
 * @return an OutputStream to which content can be written.
 * @throws IOException if unable to provide the content of this
 *         Resource as a stream.
 * @throws UnsupportedOperationException if OutputStreams are not
 *         supported for this Resource type.
 */
public OutputStream getOutputStream() throws IOException {
  if (isReference()) {
    return getCheckedRef().getOutputStream();
  }
  throw new UnsupportedOperationException(
    "Use the zip task for zip output.");
}

代码示例来源:origin: org.apache.ant/ant

if (isReference()) {
  return getCheckedRef().getInputStream();
final ZipFile z = new ZipFile(getZipfile(), getEncoding());
ZipEntry ze = z.getEntry(getName());
if (ze == null) {
  z.close();
  throw new BuildException("no entry " + getName() + " in "
               + getArchive());

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

(org.apache.tools.ant.types.resources.ZipResource) r;
  org.apache.tools.zip.ZipExtraField[] extra = zr.getExtraFields();
  ZipExtraField[] ex =
    new ZipExtraField[extra == null ? 0 : extra.length];
  return new ResourceFlags(zr.getMode(), ex, zr.getMethod());
} else {
  ArchiveResource ar = (ArchiveResource) r;

代码示例来源:origin: org.apache.ant/ant

/**
 * Add a directory entry to the archive using a specified
 * Unix-mode and the default mode for its parent directories (if
 * necessary).
 */
private void addDirectoryResource(final Resource r, String name, final String prefix,
                 final File base, final ZipOutputStream zOut,
                 final int defaultDirMode, final int thisDirMode)
  throws IOException {
  if (!name.endsWith("/")) {
    name += "/";
  }
  final int nextToLastSlash = name.lastIndexOf('/', name.length() - 2);
  if (nextToLastSlash != -1) {
    addParentDirs(base, name.substring(0, nextToLastSlash + 1),
           zOut, prefix, defaultDirMode);
  }
  zipDir(r, zOut, prefix + name, thisDirMode,
      r instanceof ZipResource
      ? ((ZipResource) r).getExtraFields() : null);
}

代码示例来源:origin: HuaweiBigData/StreamCQL

/**
 * {@inheritDoc}
 */
@Override
public boolean isSelected(Resource r)
{
  if (!(r instanceof ZipResource))
  {
    return true;
  }
  
  ZipResource zip = (ZipResource)r;
  if (zip.getName().startsWith("META-INF"))
  {
    return false;
  }
  return true;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Get the zipfile that holds this ZipResource.
 * @return the zipfile as a File.
 */
public File getZipfile() {
  FileProvider fp = getArchive().as(FileProvider.class);
  return fp.getFile();
}

代码示例来源:origin: org.apache.ant/ant

Resource r = new ZipResource(srcFile, encoding, entry);
String name = entry.getName();
if (entry.isDirectory()) {

代码示例来源:origin: org.apache.ant/ant

/**
 * Add a file entry.
 */
private void addResource(final Resource r, final String name, final String prefix,
             final ZipOutputStream zOut, final int mode,
             final ZipFile zf, final File fromArchive)
  throws IOException {
  if (zf != null) {
    final ZipEntry ze = zf.getEntry(r.getName());
    if (ze != null) {
      final boolean oldCompress = doCompress;
      if (keepCompression) {
        doCompress = (ze.getMethod() == ZipEntry.DEFLATED);
      }
      try (final BufferedInputStream is = new BufferedInputStream(zf.getInputStream(ze))) {
        zipFile(is, zOut, prefix + name, ze.getTime(),
            fromArchive, mode, ze.getExtraFields(true));
      } finally {
        doCompress = oldCompress;
      }
    }
  } else {
    try (final BufferedInputStream is = new BufferedInputStream(r.getInputStream())) {
      zipFile(is, zOut, prefix + name, r.getLastModified(),
          fromArchive, mode, r instanceof ZipResource
          ? ((ZipResource) r).getExtraFields() : null);
    }
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com