JAVA
共 100 篇文章
JAVA IO 字节流实现文件copy效率比较
package jonavin.io; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class IOUtil { /** * 文件拷贝-- 一个字节一个字节拷贝 * @param srcFile * @param destFile */ public s…
2014-12-24 13:32 · JAVA
EhCache简单例子
import net.sf.ehcache.Cache; import net.sf.ehcache.CacheException; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element; public class EhCacheUtil { public static CacheManager cacheManager; private String cacheName; int maxElementsInMemory = 1000; static { if (cacheManager == null) try …
2014-10-20 17:04 · JAVA
java 读取.ini配置文件工具类
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import java.util.Properties; @SuppressWarnings("rawtypes") public class IniReader { protected HashMap sections = new HashMap(); private transient String currentSecion; private transient P…
2014-10-09 16:29 · JAVA
POI读取excel文件通用代码(增强版--支持返回javaBean集合)---2003,2007
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import net.sf.json.JSONObject; import org.apache.poi.xssf.usermodel.XSSFCell;…
HttpClient模拟get,post请求并发送请求参数(json等)
import java.io.IOException; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpExcepti…
2014-09-18 16:33 · JAVA · HttpClient
POI读取Excel通用代码---支持2003,2007
package com.citics.crm.customerwidget.utils; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; …
将数据库树形记录转为java 树形数据结构
/** * 转换为Tree结构 * @param treedata * @return */ public static Tree toTreeList(List<Tree> treedata){ Tree root = null; for(Tree node:treedata){ String parentid = node.getParentid(); if(parentid.equals("0")) root = node; Tree parent = getTarget(treedata,parentid); if(parent != null){ List<Tree> childr…
2014-08-24 18:36 · JAVA
java缓存技术学习
package com.citics.crm.customerwidget.utils; /** * <p>Description: 缓存DTO</p> * @version 1.0 */ public class Cache { private String key;//缓存ID private Object value;//缓存数据 private long timeOut;//更新时间 private boolean expired; //是否终止 public Cache() { super(); } public Cache(String key, Object value, lo…
2014-07-25 18:05 · JAVA
java unicode 转中文(学习用)
第一种方式自己实现(笨,但可以知道原理) /** * unicode 转中文 * @param str * @return */ public static String ascii2Native(String str) { StringBuilder sb = new StringBuilder(); int begin = 0; int index = str.indexOf("\\u"); while (index != -1) { sb.append(str.substring(begin, index)); sb.append(ascii2Char(str.substring(in…
2014-07-10 09:47 · JAVA
java+javascript获得两个日期之间的所有月份
java版 private static List<String> getMonthBetween(String minDate, String maxDate) throws ParseException { ArrayList<String> result = new ArrayList<String>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月 Calendar min = Calendar.getInstance(); Calendar max = Calendar.getInstance();…
2014-05-30 12:29 · JAVA
java模拟调用Servlet
public static void main(String[] args) throws Exception { Properties property = new Properties(); BufferedInputStream inBuff = null; inBuff = new BufferedInputStream(new PostRequestEmulator().getClass().getResourceAsStream("/attach.properties")); property.load(inBuff); // 服务地址 URL url = new URL(pro…
2013-12-26 13:27 · JAVA
javax 邮件发送
import java.util.Date; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.mail.Multipart; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; import javax.m…
2013-10-21 10:20 · JAVA
[JODConverter]word转pdf心得分享(转)
官方网站: http://www.artofsolving.com/opensource/jodconverter 下载地点: http://www.artofsolving.com/opensource/jodconverter http://zh.openoffice.org/new/zh_tw/downloads.html 目前版本: JODConverter v2.2.1, OpenOffice v3.0.0 使用需求: JDK1.4以上, 安装OpenOffice v2.0.3以上 基本简介: JODConverter主要的功能是用来做各种档案的转换. 目前测试过, Word,Ex…
2013-10-10 14:48 · JAVA
java MD5机密工具
/************************************************ MD5 算法的Java Bean @author:Topcat Tuppin Last Modified:10,Mar,2001 *************************************************/ /******************************************************************************* * md5 类实现了RSA Data Security, Inc.在提交给IETF 的RFC1321中的…
2013-09-13 09:33 · JAVA
JAVA 将文件转换为字节
package com.tacct.tradecontract.web; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class FileUtil { private FileUtil(){}; // 返回一个byte数组 public static byte[] getBytesFromFile(File file) throws IOException { InputStream is = new Fi…
2013-09-06 10:20 · JAVA
javaBean转Map工具类
package com.tacct.tradecontract.web; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; public class BeanToMap<K, V> { private BeanToMap() { } @SuppressWarnings("unchecked") public static <K, V> Map<K, V> Bean2Map(Object javaBean) { Map<K, V> ret = new HashMap<K, V>();…
2013-09-05 13:37 · JAVA
JAVA 操作blob数据然后生成word文件
import java.io.*; import java.sql.*; public class Test { Connection con = null; Statement stmt = null; ResultSet rs = null; private ResultSet getResultSet() { try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url = "jdbc:oracle:thin:@10.23.117.110:1521:zgzhms"; String use…
2013-09-05 11:27 · JAVA