2012 年文章归档
共 142 篇文章
对象和byte流互相转换
ByteArrayOutputStream bo = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bo); os.writeObject(obj); return bo.toByteArray(); 其中obj可以是java里的任何可序列化对象 byte流转为对象 byte[] serialize ByteArrayInputStream bis = new ByteArrayInputStream(serialize); ObjectInputStream ois = new Obj…
2012-12-14 09:22 · Java
手动解压安装的tomcat如何随机自动启动
1.在windows系统中cmd进入tomcat的bin目录 2.运行 service.bat install 这样即可将tomcat服务安装到系统中,即可以在系统服务(services.msc)中设置自动启动 注: service.bat文件里 set SERVICE_NAME=Tomcat7 服务名 set PR_DISPLAYNAME=Apache Tomcat 7 系统服务里显示的服务名称
File和InputStream互相转换
File --> InputStream InputStream in = new InputStream(new FileInputStream(file)); InputStream --> File public void inputstreamtofile(InputStream ins,File file){ OutputStream os = new FileOutputStream(file); int bytesRead = 0; byte[] buffer = new byte[8192]; while ((bytesRead = ins.read(buffer, 0, 8…
2012-12-11 13:08 · Java
httpclient上传带附件的参数
public static String getMimeType(String fileUrl) throws java.io.IOException { FileNameMap fileNameMap = URLConnection.getFileNameMap(); String type = fileNameMap.getContentTypeFor(fileUrl); return type; } // 上传带附件的参数: public static String uploadFile(String filePath, String id, int bid) { File file …
2012-12-11 08:37 · Java
css设置透明背景 适应所有浏览器
filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5; opacity: 0.5; This is the “most important” one because it is the current standard in CSS. This will work in most versions of Firefox, Safari, and Opera. This would be all you need if all browsers supported current standa…
httpclient设置请求字符集
postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
2012-11-30 11:15 · Java
httpclient获取响应头信息
String _cookies = getCookieStr(postMethod.getResponseHeader("Set-Cookie")); private String getCookieStr(Header header) { StringBuilder sb = new StringBuilder(); HeaderElement[] elements = header.getElements(); for (int i = 0; i < elements.length; i++) { HeaderElement element = elements[i]; if (!Str…
2012-11-30 11:14 · Java
常用工具
diagramdesigner 流程图 powerdesigner uml设计 yourkit_java_profiler java程序性能监测 rational rose uml设计 SharpDevelop C#轻量IDE JetBrains PyCharm python IDE Snagit 截图 filezilla ftp SQLyog Enterprise mysql数据库 UM 局域网通信 HttpWatchPro IE网页数据分析 firebug 火狐网页数据分析 SetupRegexBuddyDemo 正则表达式 VisualSVN-Serve svn server Tort…
2012-11-28 09:17 · Java
strut2 action 获取web根目录
//相对路径 String rootPath = ServletActionContext.getRequest().getContextPath(); //绝对路径 String rootPath = ServletActionContext.getServletContext().getRealPath(""); 摘自: http://www.chahushequ.com
为什么ehcache无法将数据写到硬盘
ehcache.xml中已经将overflowToDisk="true" 但当缓存数大于maxElementsInMemory时,依然没有将溢出的数据保存到硬盘 原因:如果缓存的对象要写入到硬盘中的话,则该对象必须实现了Serializable接口才行。 摘自: http://www.chahushequ.com
2012-11-20 10:45 · Java
js判断智能手机浏览器版本
<s.c.r.i.p.t type="text/javas.c.r.i.p.t"> /* * 智能机浏览器版本信息: * */ var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') >…
2012-11-15 10:42 · Js
jquery实现div从左向右弹出的效果
<div id="nav" style="width:0px;height:600px;position:fixed;left:0px;"> <div id="navcontent" style="z-index:10;background:lightgreen;width:0px;height:100%;overflow:hidden;position:fixed;"></div> <div style="z-index:1;float:left;text-align:right;cursor:hand;width:10px;height:50px;line-height:45px;bac…
2012-11-07 10:22 · Jquery
为什么Google浏览器快
http://www.chahushequ.com/read.bbscs?action=topic&id=2fa997433a97112e013a97367ac2000c&bid=36&fcpage=1&fcaction=index&tagId=0
2012-10-25 17:18 · Other
tomcat启用gzip
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool" URIEncoding="utf-8" compression="on" compressionMinSize="50" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" /…
获取当前jsp绝对路径
<% String strAbsPath=application.getRealPath(request.getRequestURI()); out.println(strAbsPath); %>
Date加一天操作
Calendar date = Calendar.getInstance(); date.setTime(myDate); date.set(Calendar.DATE, date.get(Calendar.DATE) + 1); date.getTime()即可获取加一天后的日期
2012-10-21 18:19 · Java
windows和linux下Date类型转化为string时结果不同
SimpleDateFormat df1 = new SimpleDateFormat( "yyyyMMdd"); String strDate = df1.format(myDate); 相同的日期myDate,但上面在windows和linux下的foramt结果不同 可用如下方式解决该问题 SimpleDateFormat df1 = new SimpleDateFormat( "yyyy.MM.dd hh:ss ",Locale.CHINA); 另外看一下时区设定是否正确 set JAVA_OPTS=%JAVA_OPTS% -Duser.timezone=GMT+08
tomcat7报错:java.security.AccessControlException: access denied
tomcat7报错:java.security.AccessControlException: access denied 给自己的项目目录(以ROOT为例)添加权限即可解决这个问题 grant codeBase "file:${catalina.home}/webapps/ROOT/-" { permission java.security.AllPermission; };
windows常用协议端口
ftp(21) http(80) https(443) telnett(23) smtp(25) mstsc(3389)
2012-10-19 16:20 · Windows