gpt4 book ai didi

org.apache.tools.zip.ZipOutputStream.flush()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 18:10:40 26 4
gpt4 key购买 nike

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

ZipOutputStream.flush介绍

[英]Flushes this output stream and forces any buffered output bytes to be written out to the stream.
[中]刷新此输出流,并强制将任何缓冲输出字节写入流。

代码示例

代码示例来源:origin: com.github.tianjing/tgtools.core

private void addZipEntry(InputStream p_InputStream, String p_EntryName) throws APPErrorException {
  try {
    BufferedInputStream bi = new BufferedInputStream(p_InputStream);
    // 开始写入新的ZIP文件条目并将流定位到条目数据的开始处
    ZipEntry zipEntry = new ZipEntry(p_EntryName);
    m_ZipOutputStream.putNextEntry(zipEntry);
    byte[] buffer = new byte[1024];
    int readCount = bi.read(buffer);
    while (readCount != -1) {
      m_ZipOutputStream.write(buffer, 0, readCount);
      readCount = bi.read(buffer);
    }
    // 注,在使用缓冲流写压缩文件时,一个条件完后一定要刷新一把,不
    // 然可能有的内容就会存入到后面条目中去了
    m_ZipOutputStream.flush();
  } catch (Exception ex) {
    throw new APPErrorException("压缩文件出错。文件名称:" + p_EntryName + ";原因:" + ex.getMessage(), ex);
  } finally {
    try {
      p_InputStream.close();
    } catch (IOException e) {
      LogHelper.error("", "输入流关闭错误", "ZipPackager.addFile", e);
    }
  }
}

代码示例来源:origin: com.github.tianjing/tgtools.core

/**
 * 释放
 */
@Override
public void Dispose() {
  try {
    m_ZipOutputStream.flush();
  } catch (IOException e) {
    LogHelper.error("", "flush压缩流错误", "ZipPackager.Dispose", e);
  }
  try {
    m_ZipOutputStream.close();
  } catch (IOException e) {
    LogHelper.error("", "close压缩流错误", "ZipPackager.Dispose", e);
  }
  m_ZipOutputStream = null;
}

代码示例来源:origin: com.github.javahaohao/utils

zipOut.write(buf, 0, readedBytes);
zipOut.flush();
fileIn.close();
zipOut.closeEntry();

代码示例来源:origin: hyperic/hq

zip_out.flush();
completedOK = true;

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