JavaSE
JasonYao
从事java开发3年。熟悉WAS MQ JMS SOA
展开
-
Class.forName()有参构造函数的实例化
<br />首先要知道你要实例化的类的构造函数的参数类型<br />需要提供一个类型的数组:<br />sample:Class[] paraTypes = {DecoderInfo.class,ValidationInfo.class,TransformerInfo.class,ProcessInfo.class,ErrorProcessInfo.class};<br /><br /><br />然后要提供你传入的参数值,也是用数组的形式提供,和类型数组一一对应:<br />sample:<br原创 2011-04-13 16:03:00 · 4479 阅读 · 1 评论 -
Log4j 怎么打出错误堆栈而不是一条错误message
使用logger.error(e) 这个方法相当于打出了 e.toString() 的内容。想要打出具体堆栈的信息,定位到具体哪边抛出错误的话可以使用logger.error('Some String such as 'Exception occurred'', e)原创 2013-07-01 22:58:00 · 2098 阅读 · 0 评论 -
不借助第三方类库,使用JDK自带API操作XML
先放两个主要方法:import java.io.StringReader;import java.io.StringWriter;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.transform.Source;impo原创 2013-09-27 19:34:30 · 1517 阅读 · 0 评论 -
在JAR包中使用log4j
前提概要:一个小系统,需要打成jar包的,而且在这个系统里面需要用到log4j,那么怎么能在打成后的jar包中正确加载到log4j配置文件呢?实现代码如下(不管是Eclipse环境还是jar包环境都能正确读取到log4j的配置文件):InputStream in = LogManager.class.getResourceAsStream("/com/test/log4j.xml");原创 2013-12-04 19:22:28 · 5014 阅读 · 0 评论 -
【备忘】Java LDAP 相关操作
java链接LDAP:package com.mh.ldap.demo;import java.util.Hashtable;import javax.naming.Context;import javax.naming.NamingEnumeration;import javax.naming.directory.InitialDirContext;import javax.n转载 2014-01-06 23:48:06 · 796 阅读 · 0 评论 -
推荐一款不错的eclipse properties编辑插件
大家都知道在写中文资源文件的不能直接写中文,需要通过java的native2assci进行转换,这样很bu fang bi a原创 2014-06-08 18:44:25 · 780 阅读 · 0 评论 -
java中的AES 256算法遇到 Illegal key size or default parameters错的解决办法
报错堆栈如下:Caused by: java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6] at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]原创 2012-04-13 16:07:08 · 18016 阅读 · 5 评论 -
java bean convert to json string and json string convert to java bean
package org.codehaus.jackson;import java.io.ByteArrayOutputStream;import java.io.OutputStream;import java.util.ArrayList;import java.util.List;import junit.framework.Assert;import org.codehau原创 2014-09-06 00:23:16 · 1215 阅读 · 0 评论 -
[Interview]The java exception type
java has two type of exception, one is checked exception and another is unchecked exception.checked exception inherit from the java.lang.Exception and unchecked exception inherit from java.lang.Runt原创 2014-12-24 21:13:49 · 728 阅读 · 0 评论 -
取得Spring配置文件中的Bean对象的通用方法
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** * 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候中取出ApplicaitonContext.转载 2013-02-21 22:20:20 · 2113 阅读 · 0 评论 -
读写Excel的工具类(JXL,POI,IText)
JXL 读工具类:package jason.excel.util;import java.io.File;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import jxl.Cell;import jxl.Sheet;import原创 2013-02-06 09:18:58 · 2116 阅读 · 0 评论 -
使用JUNIT4 生成测试报告
转载请注明出处!!!!!!项目不能引用到其他项目,如果引用到其他项目,需要把其他项目打成jar包,然后去引用jar包创建一个套件类,右击套件类,点export 在general里面点ant builders 构建文件,如下图所示然后点next出现如下图所示:勾选你需要出测试报告的项目PS:Name for Ant buildfile >>>>原创 2011-07-07 08:48:44 · 17172 阅读 · 3 评论 -
写了个DOM4J 的工具类。欢迎拍砖
转载请注明出处!!!package jason.xml.util;import java.util.List;import org.dom4j.Document;import org.dom4j.Element;import org.dom4j.Node;/**原创 2011-09-29 14:07:48 · 1306 阅读 · 0 评论 -
java 转整型 哪种方法速度最快?
public class NumberFormatTest { public static void main(String[] args) throws Exception { String time = "20"; long start = System.currentTimeMillis(); for (int i = 0; i < 100000; i++) { //原创 2011-11-30 10:23:37 · 123 阅读 · 0 评论 -
IBMJCE AND SunJCE(javax.crypto.BadPaddingException:Given final block not properly padded)
问题描述:项目中要用到和SFTP进行连接上传文件,用户名密码IP什么的要配置在WAS服务器里面,出于安全性考虑,需要把这些连接的必要信息用AES-256进行加密,加密自己写了一个桌面工具,把加密过后的信息放到WAS配置文件里面,但是问题来了,在应用程序运行过程中,并没有成功的解密,报错如下:javax.crypto.BadPaddingException:Given final原创 2012-05-29 10:24:57 · 5323 阅读 · 3 评论 -
SFTP 之使用 openssh
纯属备忘用:First download the setupssh.exe package and then install the opensshAfter install the software, use the command window to CD to the folder : %install_folder%/OpenSSH/binThen type the comm原创 2011-04-22 16:14:00 · 2232 阅读 · 0 评论 -
[转载,备忘]正则表达式汇总
原文地址:http://www.blogjava.net/tbwshc/archive/2012/07/05/382269.html"^\d+$" //非负整数(正整数 + 0)"^[0-9]*[1-9][0-9]*$" //正整数"^((-\d+)|(0+))$" //非正整数(负整数 + 0)"^-[0-9]*[1-9][0-9]*$" //负整数"转载 2012-07-05 18:19:23 · 574 阅读 · 0 评论 -
Use Rhino to write SSJS(Server side javascript)
package jason.Rhino.study;import java.io.File;import java.io.FileReader;import java.io.IOException;import org.mozilla.js.Context;import org.mozilla.js.ContextAction;import org.mozilla.js.Conte原创 2012-06-28 15:44:34 · 1124 阅读 · 0 评论 -
【备忘】解析HTML document 推荐使用Jsoup开源jar包
网址:http://jsoup.org/原创 2013-01-24 09:20:53 · 1397 阅读 · 1 评论 -
利用AtomicInteger实现高性能的ID生成器
废话不多说,直接上代码,目前该生成器用于生成流量平台的订单号:package com.base.common.util.idworker;import java.text.SimpleDateFormat;import java.util.Date;import java.util.concurrent.atomic.AtomicInteger;public class IdW...原创 2018-09-07 15:46:38 · 1701 阅读 · 0 评论