com.amse.ys.zip.ZipFile类的使用及代码示例

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

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

ZipFile介绍

暂无

代码示例

代码示例来源:origin: ydcx/KooReader

public InputStream getInputStream(String entryName) throws IOException {
  return createZipInputStream(getHeader(entryName)); // 取出对应的LocalFileHeader类之后
  // 以此为参数调用ZipFile类的createZipInputStream方法。这个方法带又调用了一个ZipInputStream类的构造函数
}

代码示例来源:origin: ydcx/KooReader

@Override
public long size() {
  try {
    return getZipFile(myParent).getEntrySize(myName);
  } catch (IOException e) {
    return 0;
  }
}

代码示例来源:origin: Jiangzqts/EpubRead

@Override
  public InputStream getInputStream() throws IOException {
    // epub路径,OEBPS/images/cover.jpg
    return getZipFile(myParent).getInputStream(myName);
  }
}

代码示例来源:origin: ydcx/KooReader

private void readAllHeaders() throws IOException {
  LogUtil.i21("");
  if (myAllFilesAreRead) {
    return;
  }
  myAllFilesAreRead = true;
  MyBufferedInputStream baseStream = getBaseStream();
  baseStream.setPosition(0);
  myFileHeaders.clear();
  try {
    while (baseStream.available() > 0) {
      readFileHeader(baseStream, null);
    }
  } finally {
    storeBaseStream(baseStream);
  }
}

代码示例来源:origin: ydcx/KooReader

public boolean entryExists(String entryName) {
  try {
    return getHeader(entryName) != null;
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: Jiangzqts/EpubRead

public Collection<LocalFileHeader> headers() {
  try {
    LogUtil.i1("amseys");
    readAllHeaders();
  } catch (IOException e) {
  }
  return myFileHeaders.values();
}

代码示例来源:origin: ydcx/KooReader

@Override
public boolean exists() {
  try {
    return myParent.exists() && getZipFile(myParent).entryExists(myName);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: ydcx/KooReader

public ZipInputStream(ZipFile parent, LocalFileHeader header) throws IOException {
  myParent = parent; //
  myBaseStream = parent.getBaseStream();
  myBaseStream.setPosition(header.DataOffset); // 将epub文件的字节流定位到图片文件开始的位置
  myDecompressor = Decompressor.init(myBaseStream, header); // 根据不同的CompressionMethod
}

代码示例来源:origin: ydcx/KooReader

private static ZipFile getZipFile(final ZLFile file) throws IOException {
  synchronized (ourZipFileMap) {
    LogUtil.i21(""); // 图片打开时用到
    ZipFile zf = file.isCached() ? ourZipFileMap.get(file) : null;
    if (zf == null) {
      zf = new ZipFile(file);
      if (file.isCached()) {
        // 不走
        ourZipFileMap.put(file, zf);
      }
    }
    return zf;
  }
}

代码示例来源:origin: ydcx/KooReader

static List<ZLFile> archiveEntries(ZLFile archive) {
  try {
    final ZipFile zf = ZLZipEntryFile.getZipFile(archive);
    final Collection<LocalFileHeader> headers = zf.headers();
    if (!headers.isEmpty()) {
      ArrayList<ZLFile> entries = new ArrayList<ZLFile>(headers.size());
      for (LocalFileHeader h : headers) {
        entries.add(new ZLZipEntryFile(archive, h.FileName));
      }
      return entries;
    }
  } catch (IOException e) {
  }
  return Collections.emptyList();
}

代码示例来源:origin: Jiangzqts/EpubRead

private boolean readFileHeader(MyBufferedInputStream baseStream, String fileToFind) throws IOException { // 图片调用
  LocalFileHeader header = new LocalFileHeader();
  header.readFrom(baseStream); // LocalFileHeader中
  if (header.Signature != LocalFileHeader.FILE_HEADER_SIGNATURE) {
    return false;
  }
  if (header.FileName != null) {
    // 创建出的LocalFileHeader被加入到myFileHeaders
    myFileHeaders.put(header.FileName, header);
    if (header.FileName.equalsIgnoreCase(fileToFind)) {
      return true;
    }
  }
  if ((header.Flags & 0x08) == 0) {
    baseStream.skip(header.CompressedSize);
  } else {
    findAndReadDescriptor(baseStream, header);
  }
  return false;
}

代码示例来源:origin: Jiangzqts/EpubRead

private void readAllHeaders() throws IOException {
  LogUtil.i21("");
  if (myAllFilesAreRead) {
    return;
  }
  myAllFilesAreRead = true;
  MyBufferedInputStream baseStream = getBaseStream();
  baseStream.setPosition(0);
  myFileHeaders.clear();
  try {
    while (baseStream.available() > 0) {
      readFileHeader(baseStream, null);
    }
  } finally {
    storeBaseStream(baseStream);
  }
}

代码示例来源:origin: Jiangzqts/EpubRead

public boolean entryExists(String entryName) {
  try {
    return getHeader(entryName) != null;
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: ydcx/KooReader

public Collection<LocalFileHeader> headers() {
  try {
    LogUtil.i1("amseys");
    readAllHeaders();
  } catch (IOException e) {
  }
  return myFileHeaders.values();
}

代码示例来源:origin: Jiangzqts/EpubRead

@Override
public boolean exists() {
  try {
    return myParent.exists() && getZipFile(myParent).entryExists(myName);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: Jiangzqts/EpubRead

public ZipInputStream(ZipFile parent, LocalFileHeader header) throws IOException {
  myParent = parent; //
  myBaseStream = parent.getBaseStream();
  myBaseStream.setPosition(header.DataOffset); // 将epub文件的字节流定位到图片文件开始的位置
  myDecompressor = Decompressor.init(myBaseStream, header); // 根据不同的CompressionMethod
}

代码示例来源:origin: Jiangzqts/EpubRead

private static ZipFile getZipFile(final ZLFile file) throws IOException {
  synchronized (ourZipFileMap) {
    LogUtil.i21(""); // 图片打开时用到
    ZipFile zf = file.isCached() ? ourZipFileMap.get(file) : null;
    if (zf == null) {
      zf = new ZipFile(file);
      if (file.isCached()) {
        // 不走
        ourZipFileMap.put(file, zf);
      }
    }
    return zf;
  }
}

代码示例来源:origin: Jiangzqts/EpubRead

static List<ZLFile> archiveEntries(ZLFile archive) {
  try {
    final ZipFile zf = ZLZipEntryFile.getZipFile(archive);
    final Collection<LocalFileHeader> headers = zf.headers();
    if (!headers.isEmpty()) {
      ArrayList<ZLFile> entries = new ArrayList<ZLFile>(headers.size());
      for (LocalFileHeader h : headers) {
        entries.add(new ZLZipEntryFile(archive, h.FileName));
      }
      return entries;
    }
  } catch (IOException e) {
  }
  return Collections.emptyList();
}

代码示例来源:origin: ydcx/KooReader

private boolean readFileHeader(MyBufferedInputStream baseStream, String fileToFind) throws IOException { // 图片调用
  LocalFileHeader header = new LocalFileHeader();
  header.readFrom(baseStream); // LocalFileHeader中
  if (header.Signature != LocalFileHeader.FILE_HEADER_SIGNATURE) {
    return false;
  }
  if (header.FileName != null) {
    // 创建出的LocalFileHeader被加入到myFileHeaders
    myFileHeaders.put(header.FileName, header);
    if (header.FileName.equalsIgnoreCase(fileToFind)) {
      return true;
    }
  }
  if ((header.Flags & 0x08) == 0) {
    baseStream.skip(header.CompressedSize);
  } else {
    findAndReadDescriptor(baseStream, header);
  }
  return false;
}

代码示例来源:origin: Jiangzqts/EpubRead

MyBufferedInputStream baseStream = getBaseStream();
baseStream.setPosition(0);
try {
  while (baseStream.available() > 0 && !readFileHeader(baseStream, entryName)) {
  storeBaseStream(baseStream);

相关文章