使用javatar解压tar包等
2015-09-25 10:46
483 查看
1、下载javatar-2.5.jar
资源:http://pan.baidu.com/s/1pJOQ6wz
2、使用方法:
3、测试
资源:http://pan.baidu.com/s/1pJOQ6wz
2、使用方法:
/** * 解压tar包 * * @author: kpchen@iflyte.com * @createTime: 2015年9月23日 下午5:41:56 * @history: * @param filename * tar文件 * @param directory * 解压目录 * @return */ private static boolean extTarFileList(String filename, String directory) { boolean flag = false; OutputStream out = null; try { TarInputStream in = new TarInputStream(new FileInputStream(new File(filename))); TarEntry entry = null; while ((entry = in.getNextEntry()) != null) { if (entry.isDirectory()) { continue; } System.out.println(entry.getName()); File outfile = new File(directory + entry.getName()); new File(outfile.getParent()).mkdirs(); out = new BufferedOutputStream(new FileOutputStream(outfile)); int x = 0; while ((x = in.read()) != -1) { out.write(x); } out.close(); } in.close(); flag = true; } catch (IOException ioe) { ioe.printStackTrace(); flag = false; } return flag; }
3、测试
extTarFileList("D:/Test/ibs/20150925.tar", "D:/Test/ibs/temp/");
相关文章推荐
- java的标识符
- java各数据库的连接字符串
- 基于JPA规范的spring-data-jpa面向对象的查询方法举例
- java环境变量中 JAVA_HOME,Path,CLASSPAHT 的解释
- SpringMVC 基于注解的Controller详解
- eclipse安装maven插件
- org.springframework.web.multipart.commons.CommonsMultipartFile异常
- 【原创】MyEclipse反编译添加jadclipse_3.3.0 曲折的完美解决
- java List集合去重
- Java之旅Spring框架学习(2)——让你的编程变得“被动”
- 随机素数测试 Miller Rabin 质因数分解 pollard_rho Java版 模板
- Java基础知识强化80:Math类random()方法的小扩展(控制产生目的数字的概率)
- java 内部类
- Java面向对象三大特征:封装、继承、多态
- Java删除指定文件夹下的所有内容(包括此文件夹)
- SpringMVC与Freemark整合,多视图完美展示详细完美解决
- java SOF
- struts2 异常处理 404错误
- ConcurrentHashMap实现解析
- java OOM