gpt4 book ai didi

java.util.zip.ZipException.initCause()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 13:40:40 27 4
gpt4 key购买 nike

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

ZipException.initCause介绍

暂无

代码示例

代码示例来源:origin: spotbugs/spotbugs

e2.initCause(e);
throw e2;

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

/**
 * Potentially reads more bytes to fill the inflater's buffer and
 * reads from it.
 */
private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException {
  int read = 0;
  do {
    if (inf.needsInput()) {
      final int l = fill();
      if (l > 0) {
        current.bytesReadFromStream += buf.limit();
      } else if (l == -1) {
        return -1;
      } else {
        break;
      }
    }
    try {
      read = inf.inflate(buffer, offset, length);
    } catch (final DataFormatException e) {
      throw (IOException) new ZipException(e.getMessage()).initCause(e);
    }
  } while (read == 0 && inf.needsInput());
  return read;
}

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

+ Integer.toHexString(headerId.getValue())).initCause(aiobe);
throw (ZipException) new ZipException(ie.getMessage()).initCause(ie);

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

/**
   * Constructs a ZIP parameters exception with
   * the given cause.
   *
   * @param cause the cause for this exception to get thrown.
   */
  public ZipParametersException(@CheckForNull Throwable cause) {
    super(null != cause ? cause.toString() : null);
    super.initCause(cause);
  }
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

/**
 * Constructs a ZIP crypto exception with
 * the given detail message and cause.
 *
 * @param msg the detail message.
 * @param cause the cause for this exception to be thrown.
 */
public ZipCryptoException(@CheckForNull String msg, @CheckForNull Throwable cause) {
  super(msg);
  super.initCause(cause);
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

/**
   * Constructs a ZIP crypto exception with
   * the given cause.
   *
   * @param cause the cause for this exception to get thrown.
   */
  public ZipCryptoException(@CheckForNull Throwable cause) {
    super(null != cause ? cause.toString() : null);
    super.initCause(cause);
  }
}

代码示例来源:origin: org.eclipse.jetty.spdy/spdy-core

@Override
  public int decompress(byte[] output) throws ZipException
  {
    try
    {
      return inflater.inflate(output);
    }
    catch (DataFormatException x)
    {
      throw (ZipException)new ZipException().initCause(x);
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

/**
 * Returns a ZipFile. Same as calling
 * new ZipFile(file)
 * @param file the file to get a ZipFile for
 * @return a ZipFile
 * @throws IOException if an error occured
 */
public ZipFile getZipFile(final File file) throws IOException {
  try {
    if (System.getSecurityManager() == null)
      return new ZipFile(file);
    try {
      return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() {
        public ZipFile run() throws IOException {
          return new ZipFile(file);
        }
      }, controlContext);
    } catch (PrivilegedActionException e) {
      if (e.getException() instanceof IOException)
        throw (IOException) e.getException();
      throw (RuntimeException) e.getException();
    }
  } catch (ZipException e) {
    ZipException zipNameException = new ZipException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$
    zipNameException.initCause(e);
    throw zipNameException;
  } catch (IOException e) {
    throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$
  }
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

/**
 * Returns a ZipFile. Same as calling
 * new ZipFile(file)
 * @param file the file to get a ZipFile for
 * @return a ZipFile
 * @throws IOException if an error occured
 */
public ZipFile getZipFile(final File file) throws IOException {
  try {
    if (System.getSecurityManager() == null)
      return new ZipFile(file);
    try {
      return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() {
        public ZipFile run() throws IOException {
          return new ZipFile(file);
        }
      }, controlContext);
    } catch (PrivilegedActionException e) {
      if (e.getException() instanceof IOException)
        throw (IOException) e.getException();
      throw (RuntimeException) e.getException();
    }
  } catch (ZipException e) {
    ZipException zipNameException = new ZipException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$
    zipNameException.initCause(e);
    throw zipNameException;
  } catch (IOException e) {
    throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

zipNameException.initCause(e);
  throw zipNameException;
} catch (IOException e) {

代码示例来源:origin: org.eclipse/osgi

zipNameException.initCause(e);
  throw zipNameException;
} catch (IOException e) {

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

zipNameException.initCause(e);
  throw zipNameException;
} catch (IOException e) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

zipNameException.initCause(e);
  throw zipNameException;
} catch (IOException e) {

代码示例来源:origin: org.eclipse/org.eclipse.osgi

zipNameException.initCause(e);
  throw zipNameException;
} catch (IOException e) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-bootstrap

} catch (FileNotFoundException ex) {
  if (ex.getMessage().contains("Too many open files")) {
    throw (ZipException)new ZipException(ex.getMessage()).initCause(ex);
  } else {
    throw ex;

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

private Jar buildFromZip(File file) throws IOException {
  try {
    zipFile = new ZipFile(file);
    for (ZipEntry entry : Iterables.iterable(zipFile.entries())) {
      if (entry.isDirectory()) {
        continue;
      }
      putResource(entry.getName(), new ZipResource(zipFile, entry), true);
    }
    return this;
  } catch (ZipException e) {
    IO.close(zipFile);
    ZipException ze = new ZipException(
      "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage());
    ze.initCause(e);
    throw ze;
  } catch (FileNotFoundException e) {
    IO.close(zipFile);
    throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath(), e);
  } catch (IOException e) {
    IO.close(zipFile);
    throw e;
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

private Jar buildFromZip(File file) throws IOException {
  try {
    zipFile = new ZipFile(file);
    for (ZipEntry entry : Iterables.iterable(zipFile.entries())) {
      if (entry.isDirectory()) {
        continue;
      }
      putResource(entry.getName(), new ZipResource(zipFile, entry), true);
    }
    return this;
  } catch (ZipException e) {
    IO.close(zipFile);
    ZipException ze = new ZipException(
      "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage());
    ze.initCause(e);
    throw ze;
  } catch (FileNotFoundException e) {
    IO.close(zipFile);
    throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath(), e);
  } catch (IOException e) {
    IO.close(zipFile);
    throw e;
  }
}

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

/**
 * Potentially reads more bytes to fill the inflater's buffer and
 * reads from it.
 */
private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException {
  int read = 0;
  do {
    if (inf.needsInput()) {
      final int l = fill();
      if (l > 0) {
        current.bytesReadFromStream += buf.limit();
      } else if (l == -1) {
        return -1;
      } else {
        break;
      }
    }
    try {
      read = inf.inflate(buffer, offset, length);
    } catch (final DataFormatException e) {
      throw (IOException) new ZipException(e.getMessage()).initCause(e);
    }
  } while (read == 0 && inf.needsInput());
  return read;
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

/**
 * Potentially reads more bytes to fill the inflater's buffer and
 * reads from it.
 */
private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException {
  int read = 0;
  do {
    if (inf.needsInput()) {
      final int l = fill();
      if (l > 0) {
        current.bytesReadFromStream += buf.limit();
      } else if (l == -1) {
        return -1;
      } else {
        break;
      }
    }
    try {
      read = inf.inflate(buffer, offset, length);
    } catch (final DataFormatException e) {
      throw (IOException) new ZipException(e.getMessage()).initCause(e);
    }
  } while (read == 0 && inf.needsInput());
  return read;
}

代码示例来源:origin: org.apache.maven.shared/maven-dependency-analyzer

public Set<String> analyze( URL url )
    throws IOException
  {
    CollectorClassFileVisitor visitor = new CollectorClassFileVisitor();

    try
    {
      ClassFileVisitorUtils.accept( url, visitor );
    }
    catch ( ZipException e )
    {
      // since the current ZipException gives no indication what jar file is corrupted
      // we prefer to wrap another ZipException for better error visibility
      ZipException ze =
        new ZipException( "Cannot process Jar entry on URL: " + url + " due to " + e.getMessage() );
      ze.initCause( e );
      throw ze;
    }

    return visitor.getClasses();
  }
}

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