- 浏览: 862614 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (509)
- android (55)
- CSS (23)
- eclipse (25)
- Data Structes and Algorithms (53)
- J2SE (87)
- Java_面试学习_j2se (26)
- java_面试学习_非技术 (13)
- java_gui (2)
- java_设计模式 (27)
- JDBC (10)
- java_web (15)
- hibernate (5)
- Oracle (37)
- Struts2 (7)
- Word-----dos (24)
- Jbpm (3)
- java小技巧 (8)
- math (1)
- flex (12)
- WebService (4)
- 生活 (9)
- 小框架或小语言 (27)
- spring (1)
- 面试~~~软实力 (7)
- jstat的用法 (1)
- jmap (1)
- 数据链路层和传输层的流量控制区别 (1)
- shell (0)
- 财商 (1)
- javascript (0)
- js研究 (1)
- 代码收集 (0)
最新评论
-
海尔群:
http://jingyan.baidu.com/articl ...
android加密 -
完美天龙:
------------------------- ...
asm----字节码操纵 -
houniao1990:
大神,请问 string 类型 定义为 oracle的 cha ...
hibernate注解 -
JamesQian:
Line:103
f.doFilter(msg);
是否需 ...
责任链模式_过滤器模式 -
sacoole:
好评
interview--- 如何从N个数中选出最大(小)的n个数?
private InitData getInitFile(String path) { Properties p = new Properties(); try { ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream( new FileInputStream(path))); FileOutputStream fileOut = null; ZipEntry entry = null; byte[] buf = new byte[1024]; while ((entry = zipIn.getNextEntry()) != null) { if (entry.getName().endsWith(InitData.INIT_FILE_NAME)) { p.load(zipIn); } else { zipIn.closeEntry(); } } zipIn.close(); } catch (Exception e) { logger.debug("Putting instrumented entry: error=" + e.getMessage(), e); } return new InitData(p); } 下面是把往zip里面塞一个序列化文件 public static void main(String[] args) { try { String path = "d:/aaa.war"; ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream( new FileInputStream(path))); ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream( "d:/aaa1.war")); ZipEntry entry = null; while ((entry = zipIn.getNextEntry()) != null) { ZipEntry zipOutEntry = new ZipEntry(entry.getName()); zipOutEntry.setComment(entry.getComment()); zipOutEntry.setExtra(entry.getExtra()); zipOutEntry.setTime(entry.getTime()); zipOut.putNextEntry(zipOutEntry); byte[] entryBytes = IOUtil .createByteArrayFromInputStream(zipIn); zipOut.write(entryBytes); zipOut.flush(); zipOut.closeEntry(); } Test t = new Test(); t.setName("aaaa"); ZipEntry outputEntry = new ZipEntry("test.ser"); zipOut.putNextEntry(outputEntry); ByteArrayOutputStream b = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(b); o.writeObject(t); byte[] entryBytes = b.toByteArray(); zipOut.write(entryBytes); zipOut.closeEntry(); zipIn.close(); zipOut.close(); File f = new File(path); f.delete(); File ff = new File("d:/aaa1.war"); ff.renameTo(f); } catch (Exception e) { System.out.println(e); } } //下面这个是解压的 public void setFileItem(FileItem fileItem) throws Exception { String baseDir = super.getSrcPath(); BufferedOutputStream dest = null; ZipInputStream zis = new ZipInputStream(new BufferedInputStream( fileItem.getInputStream())); ZipEntry entry; this.mkdirs(baseDir); while ((entry = zis.getNextEntry()) != null) { int count; byte data[] = new byte[BUFFER]; // write the files to the disk String entryName = entry.getName(); String path = baseDir + entryName; File file = new File(path); if (entry.isDirectory()) { file.mkdirs(); } else { this.mkdirs(path); FileOutputStream fos = new FileOutputStream(path); dest = new BufferedOutputStream(fos, BUFFER); while ((count = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } } if(dest!=null){ dest.flush(); dest.close(); } zis.closeEntry(); } zis.close(); this.srcPath = baseDir + fileItem.getFieldName(); } private void mkdirs(String path) { path = path.replace("\\", "/"); path = path.substring(0, path.lastIndexOf("/")); File file = new File(path); if (!file.exists()) file.mkdirs(); } 删除目录 private void deleteDirs(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (File f : files) { if (f.isFile()) f.delete(); else { deleteDirs(f); } } file.delete(); } else { file.delete(); } }
发表评论
-
jdbc--批处理
2012-06-08 18:15 1076http://jdgnewtouch.iteye.com/bl ... -
jdbc
2012-06-07 20:51 856http://www.iteye.com/topic/6466 ... -
j2se----jdk6---httpServer
2012-06-05 20:42 1345package com.tdt.server.httpse ... -
j2se基础---ThreadLocal
2012-06-02 20:47 1017package cn.itcast.heima2; ... -
获取运行时的堆栈信息
2011-12-11 11:00 2130public class Hi { public st ... -
简说XML的解析方式(DOM,SAX,StAX)
2011-09-30 08:44 872一般来说,解析XML文件存在着两种方式,一种是event-ba ... -
j2se----Java异步socket
2011-07-11 17:10 1404用异步输入输出流编写Socket进程通信程序 在Merlin ... -
j2se----socket的缓冲区讨论
2011-07-08 19:52 1728关于socket的发送缓冲区 ... -
Tomcat的Socket实现:org.apache.tomcat.util.net(一)
2011-07-08 19:12 1649org.apache.tomcat.util.net包的内容都 ... -
翻转句子中单词的顺序
2011-07-07 22:42 1703题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺 ... -
j2se---同步的Map
2011-07-07 20:50 975顾名思义LinkedHashMap是比HashMap多了一个链 ... -
j2se---同步的Map
2011-07-07 20:48 10Map<String String> map = ... -
asm----字节码操纵
2011-06-30 09:14 3875想通过asm的代码生成来写.class文件至少得了解下面的 ... -
j2se----java中,如何获得用户当前的工作目录
2011-05-11 09:44 1816获得当前路径, get java current dire ... -
j2se-----可变参数列表
2011-04-01 10:53 838public static void main(Strin ... -
UML
2010-12-31 09:42 866组合: 一种强聚合 class Bird{ ... -
j2se-----metadata
2010-12-19 17:14 984DatabaseMetaData的用法 ... -
python------一小时学会
2010-12-08 16:28 1870先上java与python的相互调用 如何在Java中调用Jy ... -
j2ee------download.jsp
2010-12-08 13:39 1092Logger logger = C ... -
effective------equals , hashCode
2010-11-22 12:04 1019覆盖equals时总是覆盖hashCode :你都认为他 ...
相关推荐
毕业设计论文-IT计算机-设计J2SE模拟MVC的企业人事管理系统源码-源码.zip
识别QR二维码,包含图片剪裁,高斯滤波去噪,二值化,投影等,内含zxing-core-1.7和zxing-j2se-1.7的Zxing开源库
jaxmpp的一些相关jar包,包括:jaxmpp-core-3.0.0.jar,jaxmpp-j2se-3.0.0.jar,tigase-utils-3.4.4.jar,tigase-xmltools-3.4.4.jar,欢迎下载
航空售票系统 学生作品
关于java编程学习的,从入门到精通的源码,非常适用于初学者哦!
面向后台,j2se部分都是基础,主要学习: 面向对-Java-Summary-of-Basic-Learning
j2se6
J2SE核心技术基础(上).zipJ2SE核心技术基础(上).zipJ2SE核心技术基础(上).zipJ2SE核心技术基础(上).zipJ2SE核心技术基础(上).zipJ2SE核心技术基础(上).zipJ2SE核心技术基础(上).zip
j2se6.chm.zip
JAVA参考大全.J2SE
J2SE6.0_Api_CN网页版给大家分享!
毕业设计-设计J2SE模拟MVC的企业人事管理系统源码
解压密码fuqingjian,这个apidoc文档你花20分下载都值,全中文解释,把你看到爽技术不想提高都难,之前有个恶心的把这个文档分成18份,结果下完只有17分,没办法解压,花了我好多分。
J2SE_Java_Api是j2se开发使用的api
提供完整的J2SE 1.3,1.4,1.5,1.6,1.7,1.8 API,供需要查阅差异的朋友查看,方便查看各版本之间的差异,更好的处理是否写的代码都兼容各版本.
优秀毕业设计论文+源码.rar基于ASP企业人事管理系统的设计与实现源码+WORD论文文档.zip基于Java的图书馆借阅管理系统源码+毕业设计论文文档.zip基于Swing技术下的酒店客房信息管理系统源码基于安卓Android学生考勤...
J2SE进阶.zip
设计J2SE模拟MVC的企业人事管理系统源码及文档.zip
设计J2SE模拟MVC的企业人事管理系统源码.zip
这是一个我最新下载Jcreatorpro.v3版本,免费提供给大家使用