android文件或文件夹压缩
来源:互联网 发布:洛阳 知乎 编辑:程序博客网 时间:2024/05/23 16:43
private static final int BUFFER = 1024 * 1024;/** * 压缩目录 * * @param File * dir * @param ZipOutputStream * out * @param String * basedir */private void compress2Directory(File dir, ZipOutputStream out,String basedir) {if (!dir.exists())return;File[] files = dir.listFiles();if(files!=null && files.length !=0){for (int i = 0; i < files.length; i++) {compress(files[i], out, basedir + dir.getName() + "/");}}}/** * 压缩文件 * * @param File * file * @param ZipOutputStream * out * @param String * basedir */private void compress2File(File file, ZipOutputStream out, String basedir) {if (!file.exists()) {return;}BufferedInputStream bis = null;try {bis = new BufferedInputStream(new FileInputStream(file));ZipEntry entry = new ZipEntry(basedir + file.getName());out.putNextEntry(entry);int count;byte data[] = new byte[BUFFER];while ((count = bis.read(data, 0, BUFFER)) != -1) {out.write(data, 0, count);}} catch (Exception e) {Write.debug(""+e.getMessage());}finally {try {bis.close();} catch (IOException e) {Write.debug(""+e.getMessage());}}}public void compress(File file, ZipOutputStream out, String basedir) {if (file.isFile()) {this.compress2File(file, out, basedir);} else {this.compress2Directory(file, out, basedir);}}
0 0
- android文件或文件夹压缩
- java压缩文件夹或文件
- java压缩文件夹或文件的方法
- java实现将文件或文件夹压缩
- java将文件夹或文件进行压缩
- 使用java对文件或文件夹进行压缩和加密
- 使用ZipArchive压缩打包想要的文件夹或文件
- 使用java对文件或文件夹进行压缩和加密
- 使用java对文件或文件夹进行压缩和加密
- 对文件或文件夹进行压缩解压加密解密
- 使用zip对文件或文件夹进行压缩, 解压缩
- 使用zip对文件或文件夹进行压缩, 解压缩
- 使用java对文件或文件夹进行压缩和加密
- 使用java对文件或文件夹进行压缩和加密
- 使用java对文件或文件夹进行压缩和加密
- 使用java对文件或文件夹进行压缩和加密
- java实现压缩指定文件夹(文件夹包含子文件夹或文件)为zip格式压缩包
- android--删除文件或递归删除文件夹
- Matlab使用过程中内存不足问题的总结
- 6.1. Maven Command Line Options
- Codeforces #292 Div 1 简要题解
- Combox 扩展
- 北洋
- android文件或文件夹压缩
- nginx的反向代理和负载均衡的区别是什么
- 【RTSP/RTP流媒体】10、编写简单的RTSP客户端
- 完成端口(Completion Port)详解
- linux下安装jdk
- 【深入JAVA】程序打包成Jar包运行并读取外部配置文件
- Epoll的实现代码浅析
- POJ 1852 Ants
- Android studio 开发中遇到问题