ITeye博客

tianyalinfeng

tianyalinfeng · 共 355 篇文章

junit中before和beforeclass区别

before在每个测试方法之前都会运行一次,只需声明成public beforeclass在类中只运行一次,必须声明成public static

2013-01-03 10:09 · Java · 评论(0)

对象和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 · 评论(0)

手动解压安装的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 系统服务里显示的服务名称

2012-12-13 09:38 · Java · Tomcat · 评论(0)

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 · 评论(0)

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 · 评论(0)

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…

2012-12-05 11:27 · Java · Html · 评论(0)

httpclient设置请求字符集

postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");

2012-11-30 11:15 · Java · 评论(0)

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 · 评论(0)

常用工具

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 · 评论(0)

strut2 action 获取web根目录

//相对路径 String rootPath = ServletActionContext.getRequest().getContextPath(); //绝对路径 String rootPath = ServletActionContext.getServletContext().getRealPath(""); 摘自: http://www.chahushequ.com

2012-11-21 10:54 · Java · Struts · 评论(0)

为什么ehcache无法将数据写到硬盘

ehcache.xml中已经将overflowToDisk="true" 但当缓存数大于maxElementsInMemory时,依然没有将溢出的数据保存到硬盘 原因:如果缓存的对象要写入到硬盘中的话,则该对象必须实现了Serializable接口才行。 摘自: http://www.chahushequ.com

2012-11-20 10:45 · Java · 评论(0)

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 · 评论(0)

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 · 评论(0)

设置页面滚动时body背景不动

background:url(../images/0419.gif) fixed;

2012-10-26 16:59 · Css · 评论(0)

为什么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 · 评论(0)