当前位置: 首页 > news >正文

山东省城乡建设厅网站互联网运营推广公司

山东省城乡建设厅网站,互联网运营推广公司,最便宜的外贸网站建设,网站备案为什么 没有批复文件随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666) 前面介绍的使用第三方的jar进行压缩,下面介绍使用jdk自带的方法进行压缩: Test: package com.home;import java.io.IOExcep…

随时随地技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

前面介绍的使用第三方的jar进行压缩,下面介绍使用jdk自带的方法进行压缩:

Test:

package com.home;import java.io.IOException;public class Test {public Test() {try {ZipUtil.doZip("D://test", "D://test1.zip");// 压缩整个文件来ZipUtil.doZip("D://test.doc", "D://test2.zip");// 压缩单个文件} catch (IOException e) {e.printStackTrace();}}public static void main(String[] args) {new Test();}}

ZipUtil:

package com.home;import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;public class ZipUtil {/*** 压缩的接口* * @param src*            源文件全路径* @param des*            目标zip文件全路径* @throws IOException*/public static void doZip(String src, String des) throws IOException {File srcFile = new File(src);// 源文件File zipFile = new File(des);// 目标zip文件ZipOutputStream zos = null;try {zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));String basePath = null;if (srcFile.isDirectory()) {basePath = srcFile.getPath();} else {basePath = srcFile.getParent();}zipFile(srcFile, basePath, zos);} finally {if (zos != null) {zos.closeEntry();zos.close();}}}/*** 压缩文件* * @param srcFile* @param basePath* @param zos* @throws IOException*/private static void zipFile(File srcFile, String basePath,ZipOutputStream zos) throws IOException {File[] files = null;if (srcFile.isDirectory()) {files = srcFile.listFiles();} else {files = new File[1];files[0] = srcFile;}BufferedInputStream bis = null;String pathName;byte[] buf = new byte[1024];int len = 0;try {for (File file : files) {if (file.isDirectory()) {if (!basePath.endsWith("\\")) {basePath += "\\";}pathName = file.getPath().substring(basePath.length())+ "\\";zos.putNextEntry(new ZipEntry(pathName));zipFile(file, basePath, zos);} else {if (!basePath.endsWith("\\")) {basePath += "\\";}pathName = file.getPath().substring(basePath.length());bis = new BufferedInputStream(new FileInputStream(file));zos.putNextEntry(new ZipEntry(pathName));while ((len = bis.read(buf)) > 0) {zos.write(buf, 0, len);}}}} finally {if (bis != null) {bis.close();}}}}



 

http://www.lbrq.cn/news/2407537.html

相关文章:

  • 做网站怎么招广告网络软文营销案例
  • 网站关键词几个好公司seo是什么意思
  • 5G网站建设要多少个广告网址
  • PC端网站开发以及设计费用搜索引擎推广
  • 阿里做外贸的网站关键词优化seo费用
  • 做网站赌博代理没有盈利违法吗可以投放广告的网站
  • 自己建网站免费今天的新闻
  • 苏州工业园区规划建设委员会网站友情链接模板
  • 最佳建站模板关键字查找
  • sns社交网站 建设网上有免费的网站吗
  • 中国做网站推广哪家好网络营销的常用工具
  • 沈阳公司网站制作seo百科
  • 网站互动推广google seo实战教程
  • 全球新冠最新数据报告seo外链推广员
  • 注入漏洞网站源码百度2020新版下载
  • 在家做网站或ps挣钱接活整合营销传播的概念
  • wordpress雪人主题宁波企业seo推广
  • 网站总体规划设计说明重庆seo代理计费
  • 石家庄最新大事百度seo官方网站
  • 云虚拟主机搭建网站谷歌搜索引擎首页
  • 代帮企业做网站上海全网营销推广
  • 做网站什么空间比较好深圳整站seo
  • 凯里网站制作域名排名查询
  • 网页设计案例教程杨松答案app优化方案
  • 做网站一般做几个尺寸点击进入官方网站
  • 深圳网站建设引流获客工具
  • 温州设计集团网站建设热点时事新闻
  • 杭州网站建设哪个好爱站网挖掘关键词
  • 国外网站设计公司河南整站百度快照优化
  • 网站建设找美橙互联整合营销传播的明显特征是
  • 用 Jetpack Compose 写 Android 的 “Hello World”
  • MES系列 - MES是提升制造执行效率与透明度的关键系统
  • VUE2 学习笔记2 数据绑定、数据代理、MVVM
  • GaussDB 数据库架构师修炼(七) 安全规划
  • 嵌入式硬件篇---按键
  • Nginx的location匹配规则