gpt4 book ai didi

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

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

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

ZipException.<init>介绍

[英]Constructs a new ZipException instance.
[中]构造一个新的ZipException实例。

代码示例

代码示例来源:origin: Tencent/tinker

static void throwZipException(String filename, long fileSize, String entryName, long localHeaderRelOffset, String msg, int magic) throws ZipException {
  final String hexString = Integer.toHexString(magic);
  throw new ZipException("file name:" + filename
              + ", file size" + fileSize
              + ", entry name:" + entryName
              + ", entry localHeaderRelOffset:" + localHeaderRelOffset
              + ", "
              + msg + " signature not found; was " + hexString);
}

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

/**
   * 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 ZipException on error
   */
  public void parseFromLocalFileData(byte[] data, int offset, int length)
    throws ZipException {
    if (length != 0) {
      throw new ZipException("JarMarker doesn't expect any data");
    }
  }
}

代码示例来源:origin: pxb1988/dex2jar

static void throwZipException(String msg, int magic) throws ZipException {
  final String hexString = String.format("0x%08x", magic);
  throw new ZipException(msg + " signature not found; was " + hexString);
}

代码示例来源: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 ZipException on error
 */
@Override
public void parseFromLocalFileData(final byte[] data, final int offset, final int length)
  throws ZipException {
  if (length != 0) {
    throw new ZipException("JarMarker doesn't expect any data");
  }
}

代码示例来源:origin: alibaba/mdrill

/**
   * 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 ZipException on error
   */
  public void parseFromLocalFileData(byte[] data, int offset, int length)
    throws ZipException {
    if (length != 0) {
      throw new ZipException("JarMarker doesn't expect any data");
    }
  }
}

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

private void write() throws IOException, ZipException {
  try {
    int inflated;
    while ((inflated = inf.inflate(buf)) > 0) {
      out.write(buf, 0, inflated);
    }
  } catch (DataFormatException e) {
    throw new ZipException();
  }
}

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

@Override
public void parseFromLocalFileData(final byte[] buffer, final int offset, final int length)
  throws ZipException {
  if (length < 5) {
    throw new ZipException("UniCode path extra data must have at least 5 bytes.");
  }
  final int version = buffer[offset];
  if (version != 0x01) {
    throw new ZipException("Unsupported version [" + version
                + "] for UniCode path extra data.");
  }
  nameCRC32 = ZipLong.getValue(buffer, offset + 1);
  unicodeName = new byte[length - 5];
  System.arraycopy(buffer, offset + 5, unicodeName, 0, length - 5);
  data = null;
}

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

/** {@inheritDoc} */
public void parseFromLocalFileData(final byte[] buffer, final int offset, final int length)
  throws ZipException {
  if (length < 5) {
    throw new ZipException("UniCode path extra data must have at least"
                + " 5 bytes.");
  }
  final int version = buffer[offset];
  if (version != 0x01) {
    throw new ZipException("Unsupported version [" + version
                + "] for UniCode path extra data.");
  }
  nameCRC32 = ZipLong.getValue(buffer, offset + 1);
  unicodeName = new byte[length - 5];
  System.arraycopy(buffer, offset + 5, unicodeName, 0, length - 5);
  data = null;
}

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

/**
 * Searches for the and positions the stream at the start of the
 * &quot;End of central dir record&quot;.
 */
private void positionAtEndOfCentralDirectoryRecord()
  throws IOException {
  final boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
                     ZipOutputStream.EOCD_SIG);
  if (!found) {
    throw new ZipException("archive is not a ZIP archive");
  }
}

代码示例来源:origin: alibaba/mdrill

/**
 * Searches for the and positions the stream at the start of the
 * &quot;End of central dir record&quot;.
 */
private void positionAtEndOfCentralDirectoryRecord()
  throws IOException {
  boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
                     ZipOutputStream.EOCD_SIG);
  if (!found) {
    throw new ZipException("archive is not a ZIP archive");
  }
}

代码示例来源:origin: alibaba/mdrill

/**
 * Searches for the and positions the stream at the start of the
 * &quot;End of central dir record&quot;.
 */
private void positionAtEndOfCentralDirectoryRecord()
  throws IOException {
  boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
                     ZipOutputStream.EOCD_SIG);
  if (!found) {
    throw new ZipException("archive is not a ZIP archive");
  }
}

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

@Override
  public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException {
    if (length < BASE_SIZE) {
      throw new ZipException("Too short content for ResourceAlignmentExtraField (0xa11e): " + length);
    }
    int alignmentValue = ZipShort.getValue(buffer, offset);
    this.alignment = (short) (alignmentValue & (ALLOW_METHOD_MESSAGE_CHANGE_FLAG - 1));
    this.allowMethodChange = (alignmentValue & ALLOW_METHOD_MESSAGE_CHANGE_FLAG) != 0;
  }
}

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

/**
 * Searches for the and positions the stream at the start of the
 * &quot;End of central dir record&quot;.
 */
private void positionAtEndOfCentralDirectoryRecord()
  throws IOException {
  final boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
                     ZipArchiveOutputStream.EOCD_SIG);
  if (!found) {
    throw new ZipException("archive is not a ZIP archive");
  }
}

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

static void throwZipException(String msg, int magic) throws ZipException {
  final String hexString = IntegralToString.intToHexString(magic, true, 8);
  throw new ZipException(msg + " signature not found; was " + hexString);
}

代码示例来源:origin: Tencent/tinker

/**
 * Writes data for the current entry to the underlying stream.
 *
 * @throws IOException
 *                If an error occurs writing to the stream
 */
@Override
public void write(byte[] buffer, int offset, int byteCount) throws IOException {
  Arrays.checkOffsetAndCount(buffer.length, offset, byteCount);
  if (currentEntry == null) {
    throw new ZipException("No active entry");
  }
  /*final long totalBytes = crc.tbytes + byteCount;
  if ((totalBytes > Zip64.MAX_ZIP_ENTRY_AND_ARCHIVE_SIZE) && !currentEntryNeedsZip64) {
    throw new IOException("Zip entry size (" + totalBytes +
        " bytes) cannot be represented in the zip format (needs Zip64)." +
        " Set the entry length using ZipEntry#setLength to use Zip64 where necessary.");
  }*/
  if (currentEntry.getMethod() == STORED) {
    out.write(buffer, offset, byteCount);
  } else {
    out.write(buffer, offset, byteCount);
  }
  // crc.update(buffer, offset, byteCount);
}
private void checkOpen() throws IOException {

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

public Callables loadProceduresFromDir( File root ) throws IOException, KernelException
{
  if ( root == null || !root.exists() )
  {
    return Callables.empty();
  }
  Callables out = new Callables();
  File[] dirListing = root.listFiles( ( dir, name ) -> name.endsWith( ".jar" ) );
  if ( dirListing == null )
  {
    return Callables.empty();
  }
  if ( !allJarFilesAreValidZipFiles( Stream.of( dirListing ) ) )
  {
    throw new ZipException( "Some jar procedure files are invalid, see log for details." );
  }
  URL[] jarFilesURLs = Stream.of( dirListing ).map( this::toURL ).toArray( URL[]::new );
  URLClassLoader loader = new URLClassLoader( jarFilesURLs, this.getClass().getClassLoader() );
  for ( URL jarFile : jarFilesURLs )
  {
    loadProcedures( jarFile, loader, out );
  }
  return out;
}

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

private void readAndVerifyDataDescriptor(int inB, int out) throws IOException {
  if (hasDD) {
    Streams.readFully(in, hdrBuf, 0, EXTHDR);
    int sig = Memory.peekInt(hdrBuf, 0, ByteOrder.LITTLE_ENDIAN);
    if (sig != (int) EXTSIG) {
      throw new ZipException(String.format("unknown format (EXTSIG=%x)", sig));
    }
    currentEntry.crc = ((long) Memory.peekInt(hdrBuf, EXTCRC, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
    currentEntry.compressedSize = ((long) Memory.peekInt(hdrBuf, EXTSIZ, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
    currentEntry.size = ((long) Memory.peekInt(hdrBuf, EXTLEN, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
  }
  if (currentEntry.crc != crc.getValue()) {
    throw new ZipException("CRC mismatch");
  }
  if (currentEntry.compressedSize != inB || currentEntry.size != out) {
    throw new ZipException("Size mismatch");
  }
}

代码示例来源:origin: Tencent/tinker

throw new ZipException("No entries");

代码示例来源:origin: Tencent/tinker

centralDirOffset = ((long) it.readInt()) & 0xffffffffL;
if (numEntries != totalNumEntries || diskNumber != 0 || diskWithCentralDir != 0) {
  throw new ZipException("Spanned archives not supported");

代码示例来源:origin: Tencent/tinker

int gpbf = it.readShort() & 0xffff;
if ((gpbf & TinkerZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
  throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
Streams.readFully(cdStream, nameBytes, 0, nameBytes.length);
if (containsNulByte(nameBytes)) {
  throw new ZipException("Filename contains NUL byte: " + Arrays.toString(nameBytes));

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