本文整理了Java中org.apache.tools.zip.ZipOutputStream.close()
方法的一些代码示例,展示了ZipOutputStream.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipOutputStream.close()
方法的具体详情如下:
包路径:org.apache.tools.zip.ZipOutputStream
类名称:ZipOutputStream
方法名:close
[英]Closes this output stream and releases any system resources associated with the stream.
[中]关闭此输出流并释放与该流关联的所有系统资源。
代码示例来源:origin: jenkinsci/jenkins
public void close() throws IOException {
zip.close();
}
代码示例来源:origin: gradle.plugin.com.bettycc.umengauto/core
private static void writePack(Map<ZipEntry, byte[]> readZipAllEntry, ZipFile file, String path, String channel)
throws Exception {
ZipOutputStream zot = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path)));
Iterator<ZipEntry> iterator = readZipAllEntry.keySet().iterator();
while (iterator.hasNext()) {
ZipEntry entry = iterator.next();
zot.putNextEntry(entry);
byte[] data = readZipAllEntry.get(entry);
zot.write(data, 0, data.length);
// System.out.println(entry);
// System.out.println(entry.getSize() + " ," +
// entry.getCompressedSize() + "," + data.length);
zot.closeEntry();
}
zot.putNextEntry(new ZipEntry("META-INF/channel_" + channel));
zot.closeEntry();
zot.close();
}
代码示例来源:origin: org.apache.ant/ant
/** Close zout */
private void closeZout(final ZipOutputStream zOut, final boolean success)
throws IOException {
if (zOut == null) {
return;
}
try {
zOut.close();
} catch (final IOException ex) {
// If we're in this finally clause because of an
// exception, we don't really care if there's an
// exception when closing the stream. E.g. if it
// throws "ZIP file must have at least one entry",
// because an exception happened before we added
// any files, then we must swallow this
// exception. Otherwise, the error that's reported
// will be the close() error, which is not the
// real cause of the problem.
if (success) {
throw ex;
}
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
public void close() throws IOException {
zip.close();
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public void close() throws IOException {
zip.close();
}
代码示例来源:origin: hudson/hudson-2.x
public void close() throws IOException {
zip.close();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public void close() throws IOException {
zip.close();
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public void close() throws IOException {
zip.close();
}
代码示例来源:origin: com.bbossgroups.pdp/pdp-system
public static void jar(String inputFileName, String outputFileName)
throws Exception {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
outputFileName));
out.setEncoding("GBK"); // ###### 这句话是关键,指定输出的编码方式
File f = new File(inputFileName);
jar(out, f, "");
out.close();
}
代码示例来源:origin: com.github.javahaohao/utils
public static boolean doZip(String srcStr, String targetStr, String targetName) {
File zipDir = new File(srcStr);
// 未指定压缩文件名,默认为"ZipFile"
if (StringUtils.isBlank(targetName))
targetName = "ZipFile";
// 添加".zip"后缀
if (!targetName.endsWith(".zip"))
targetName += ".zip";
try {
zipOut = new ZipOutputStream(new FileOutputStream(new File(targetStr + File.separator + targetName)));
// 压缩文件
compressFile(zipDir, "", zipOut);
zipOut.close();
} catch (IOException e) {
flag = false;
e.printStackTrace();
}
return flag;
}
/**
代码示例来源:origin: com.github.javahaohao/utils
/**
* @param zipDir 压缩的文件夹
* @param targetStr 压缩到的文件夹
* @param targetName 压缩成的名字
* @param suffix 后缀名
* @return 获取压缩成功标识
*/
public static boolean doFileZip(File zipDir, String targetStr, String targetName,String suffix) {
// 未指定压缩文件名,默认为"ZipFile"
if (StringUtils.isBlank(targetName))
targetName = "ZipFile";
// 添加".zip"后缀
if (!targetName.endsWith(".zip")){
targetName += "".equals(suffix)?".zip":suffix;
}
try {
zipOut = new ZipOutputStream(new FileOutputStream(new File(targetStr + File.separator + targetName)));
// 压缩文件
compressFile(zipDir, "", zipOut);
zipOut.close();
} catch (IOException e) {
flag = false;
e.printStackTrace();
}
return flag;
}
/**
代码示例来源:origin: org.jvnet.hudson.plugins/cvs
zos.close();
return null;
代码示例来源:origin: GaoFeiGit/xutils
zipStream.close();
代码示例来源:origin: GaoFeiGit/xutils
/**
* 通过HTTP下载多个文件到客户机
*
* @param response
* @param zipName
* @param pathnames
* @throws IOException
*/
public void downloadFiles(HttpServletResponse response, String zipName, String... pathnames) throws IOException {
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(zipName, UTF_8));
byte[] buf = new byte[1024];
try {
ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
for (String pathname : pathnames) {
ZipEntry entry = new ZipEntry(pathname.substring(pathname.lastIndexOf("/") + 1));
zipStream.putNextEntry(entry);
InputStream is = ftp.retrieveFileStream(pathname);
if (is != null) {
int readLen = -1;
while ((readLen = is.read(buf, 0, 1024)) != -1) {
zipStream.write(buf, 0, readLen);
}
is.close();
}
}
zipStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: GaoFeiGit/xutils
/**
* 下载多个文件到本地压缩包
*
* @param localZipPathName
* @param pathnames
* @throws IOException
*/
public void downloadFiles(String localZipPathName, String... pathnames) throws IOException {
byte[] buf = new byte[1024];
FileOutputStream fos = new FileOutputStream(localZipPathName);
try {
ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(fos));
for (String pathname : pathnames) {
ZipEntry entry = new ZipEntry(pathname.substring(pathname.lastIndexOf("/") + 1));
zipStream.putNextEntry(entry);
InputStream is = cs.get(pathname);
if (is != null) {
int readLen = -1;
while ((readLen = is.read(buf, 0, 1024)) != -1) {
zipStream.write(buf, 0, readLen);
}
is.close();
}
}
zipStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: GaoFeiGit/xutils
/**
* 下载多个文件到本地压缩包
*
* @param localZipPathName
* @param pathnames
* @throws IOException
*/
public void downloadFiles(String localZipPathName, String... pathnames) throws IOException {
byte[] buf = new byte[1024];
FileOutputStream fos = new FileOutputStream(localZipPathName);
try {
ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(fos));
for (String pathname : pathnames) {
ZipEntry entry = new ZipEntry(pathname.substring(pathname.lastIndexOf("/") + 1));
zipStream.putNextEntry(entry);
InputStream is = ftp.retrieveFileStream(pathname);
if (is != null) {
int readLen = -1;
while ((readLen = is.read(buf, 0, 1024)) != -1) {
zipStream.write(buf, 0, readLen);
}
is.close();
}
}
zipStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源: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: org.hudsonci.plugins/cvs
public Void invoke(File ws, VirtualChannel channel) throws IOException {
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(os));
if (flatten) {
archive(ws, getModuleLocations()[0].getModule(), zos, true);
} else {
for (ModuleLocation moduleLocation : getModuleLocations()) {
File mf = new File(ws, moduleLocation.getLocalDir());
if (!mf.exists()) {
// directory doesn't exist. This happens if a directory that was checked out
// didn't include any file.
continue;
}
archive(mf, ModuleLocationImpl.DEFAULT_LOCAL_DIR.equals(moduleLocation.getLocalDir())
? ModuleLocationImpl.TAGGING_SUBDIR : moduleLocation.getLocalDir(), zos, true);
}
}
zos.close();
return null;
}
});
代码示例来源:origin: GaoFeiGit/xutils
zipStream.close();
代码示例来源:origin: GaoFeiGit/xutils
zipStream.close();
内容来源于网络,如有侵权,请联系作者删除!