XenDesktop 7.5VDI无法应用自动锁屏策略在虚拟桌面中不生效,RDP下OK
2015-06-03 13:39
603 查看
最近在搞解压缩的问题,发现了用java.util.zip 是可以解压压缩包,但是解压含有中文的压缩包就会报错。所以改用ant.jar来解决这个问题,代码如下:
上面的代码已经经过测试没有问题。如有问题请留言。望多交流。
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import org.apache.tools.zip.ZipFile; public class ZipFileList { public static final int DEFAULT_BUFFER = 1024 * 4; public static long copy(InputStream aIn, OutputStream aOut, int aBufferSize) throws IOException { byte[] buffer = new byte[aBufferSize]; int read = 0; long totalBytes = 0; while (-1 != (read = aIn.read(buffer))) { aOut.write(buffer, 0, read); totalBytes += read; } return totalBytes; } public static long copy(InputStream aIn, OutputStream aOut) throws IOException { return copy(aIn, aOut, DEFAULT_BUFFER); } public static void unzip1(File zipFileName, File outputDirectory) throws Exception { ZipFile zf = null; try { zf = new ZipFile(zipFileName,"GBK"); Enumeration en = zf.getEntries(); while (en.hasMoreElements()) { org.apache.tools.zip.ZipEntry entry = (org.apache.tools.zip.ZipEntry) en .nextElement(); System.out.println(entry.getName()); FileOutputStream out = null; try { System.out.println(entry.isDirectory()); if (!entry.isDirectory()) { File newFile = new File(outputDirectory, entry.getName()); newFile.getParentFile().mkdirs(); out = new FileOutputStream(newFile); copy(zf.getInputStream(entry), out); } } catch (Exception io) { io.printStackTrace(); throw io; } finally { if (out != null) out.close(); } } } catch (IOException e) { e.printStackTrace(); } finally { try { if (zf != null) zf.close(); } catch (IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { try { ZipFileList.unzip1(new File("F:/中文.zip"), new File("f:/a")); } catch (Exception e) { e.printStackTrace(); } System.out.println("OK"); } }
上面的代码已经经过测试没有问题。如有问题请留言。望多交流。
相关文章推荐
- Tomcat默认打开项目设置
- Linux基本功
- Find命令示例(第一部分)----15个实用的Linux find命令示例
- Linux系统下C++开发工具-远程终端软件使用
- Linux开发工具的使用
- 部署Skype for Business Server 2015 数据库SQL 高可用AlwayOn
- Centos yum 安装lamp PHP5.4版本
- Ubuntu Server 与 Ubuntu Desktop之间的区别
- Linux集群之LVS
- 学习记录:linux下将C程序编译为汇编程序进行分析
- test
- CheungSSH比Ansible更优秀的Linux SSH批量管理服务器 执行命令上传下载自动化运维工具
- java.lang.ClassNotFoundException: org.apache.jsp.login_jsp
- java.lang.ClassNotFoundException: org.apache.jsp.login_jsp
- windows、linux劫持技术
- Tomcat服务器重新安装出错
- Linux应用程序学习之制作静态函数库
- 设置linux终端字符颜色
- Linux系统的时间管理
- CentOS下crontab 执行失败的原因有哪些?