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

网上申请入团网站企业查询征信

网上申请入团网站,企业查询征信,公司名字大全参考2023,营销策划方案公司接着上篇了解一下java压缩实现过程#xff0c;下面的是支持 单文件 或 文件夹 压缩的实现#xff0c;使用递归。效果#xff1a;代码#xff1a;package com.gx.compress;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;imp…接着上篇了解一下java压缩实现过程下面的是支持 单文件 或 文件夹 压缩的实现使用递归。效果代码package com.gx.compress;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.util.zip.ZipEntry;import java.util.zip.ZipOutputStream;/*** ClassName: CompressDirUtil* Description: 压缩文件工具类* author zhoujie* date 2018年7月29日 下午9:08:44* version V1.0*/public class CompressDirUtil {static String compresspath F:\\图片\\转换图片; //需要压缩的文件夹的目录public static void main(String[] args) {boolean bl compressFileToZip(compresspath); //压缩文件if(bl){System.out.println(压缩成功);}}/*** Title: compressAllFileZip* Description: 传递文件路径压缩文件传递文件夹路径压缩文件夹注空的文件夹不会出现在压缩包内* param param compresspath 需要压缩的文件夹的目录* return void 返回类型* throws*/public static boolean compressFileToZip(String compresspath) {boolean bool false;try {ZipOutputStream zipOutput null;File file new File(compresspath);if(file.isDirectory()){zipOutput new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(compresspath .zip)));compressZip(zipOutput, file, ); //递归压缩文件夹最后一个参数传压缩包就不会有当前文件夹传file.getName(),则有当前文件夹;}else{zipOutput new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(compresspath.substring(0, compresspath.lastIndexOf(.)) .zip)));zipOFile(zipOutput, file); //压缩单个文件}zipOutput.closeEntry();zipOutput.close();bool true;} catch (Exception e) {e.printStackTrace();}return bool;}/*** Title: compressZip* Description: 子文件夹中可能还有文件夹进行递归* param param zipOutput* param param file* param param suffixpath* param throws IOException* return void 返回类型* throws*/private static void compressZip(ZipOutputStream zipOutput, File file, String suffixpath) {File[] listFiles file.listFiles();// 列出所有的文件for(File fi : listFiles){if(fi.isDirectory()){if(suffixpath.equals()){compressZip(zipOutput, fi, fi.getName());}else{compressZip(zipOutput, fi, suffixpath File.separator fi.getName());}}else{zip(zipOutput, fi, suffixpath);}}}/*** Title: zip* Description: 压缩的具体操作* param param zipOutput* param param file 文件* param param suffixpath 文件夹拼接路径* return void 返回类型* throws*/public static void zip(ZipOutputStream zipOutput, File file, String suffixpath) {try {ZipEntry zEntry null;if(suffixpath.equals()){zEntry new ZipEntry(file.getName());}else{zEntry new ZipEntry(suffixpath File.separator file.getName());}zipOutput.putNextEntry(zEntry);BufferedInputStream bis new BufferedInputStream(new FileInputStream(file));byte[] buffer new byte[1024];int read 0;while((read bis.read(buffer)) ! -1){zipOutput.write(buffer, 0, read);}bis.close();} catch (Exception e) {e.printStackTrace();}}/*** Title: zip* Description: 压缩单个文件* param param zipOutput* param param file 文件* return void 返回类型* throws*/public static void zipOFile(ZipOutputStream zipOutput, File file) {try {ZipEntry zEntry new ZipEntry(file.getName());zipOutput.putNextEntry(zEntry);BufferedInputStream bis new BufferedInputStream(new FileInputStream(file));byte[] buffer new byte[1024];int read 0;while((read bis.read(buffer)) ! -1){zipOutput.write(buffer, 0, read);}bis.close();} catch (Exception e) {e.printStackTrace();}}}ok。
http://www.yutouwan.com/news/218633/

相关文章:

  • 旅游区网站开发珠海微网站
  • 做k12网站建设动漫网站的目的
  • 深圳有做网站的公司闵行广州网站建设公司
  • 浅谈电子商务网站建设网站建设在什么税控盘
  • 凡客诚品官方网站的代码wordpress防止并发数
  • 邢台网站制作深圳电商网站建设公司
  • 苏州网站建设代理江苏城乡建设职业学院就业网站
  • 中国城乡与建设部网站苏州网站关键词优化
  • wordpress 导航网站模板品牌推广案例
  • 个人网站建设作用自己建设房源网站
  • 网站业务怎么做的h5网站是什么意思
  • 导航网站教程wordpress 文章标签
  • 用wordpress建站要不要用宝塔服装业网站建设的策划
  • 建设购物网站需要多少费用公司做的网站费用如何做账
  • 网站首页模板设计图济宁网络
  • 厦门人才网官方网站请解释网站开发的主要流程
  • 新建网站站点的微信公众号链接网站开发
  • 河津网站制作网站商城微信支付接口
  • 网站建设需求文件国内做的好的电商网站有哪些
  • 哪个网站有学做吃的什么是设计方案
  • 深圳网站建设 贴吧家用电脑网站建设
  • 建设银行官方网站地址微信投放广告多少钱
  • 和平东路网站建设建设工程+质量+协会网站
  • h5建站工具网页制作教程视频简单
  • 2017网站建设报价单免费做网站推荐
  • 徐州网站建设培训千图网素材下载网站
  • 天天爱天天做视频网站做网站 什么主题较好
  • 建设网站火车票预订做网站 商标分类
  • 网站开发关于安全问题app制作手机版
  • 网站的在线支付模块怎么做电商网站建设代理商