1.Json工具
代码
package cn.org.jshuwei.j2ee.util;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* Json工具类,实现了实体类和Json数据格式之间的互转功能 使用实例:<br>
*
* <pre>
* User类:
* package cn.org.jshuwei.j2ee.util.test;
*
* public class User {
* private String userName;
* private String userPass;
* private Integer userAge;
*
* public User(){
*
* }
*
* public User(String userName, String userPass, int userAge) {
* super();
* this.userName = userName;
* this.userPass = userPass;
* this.userAge = userAge;
* }
*
* public String getUserName() {
* return userName;
* }
* public void setUserName(String userName) {
* this.userName = userName;
* }
* public String getUserPass() {
* return userPass;
* }
* public void setUserPass(String userPass) {
* this.userPass = userPass;
* }
* public Integer getUserAge() {
* return userAge;
* }
* public void setUserAge(Integer userAge) {
* this.userAge = userAge;
* }
*
* @Override
* public String toString() {
* return "name->"+this.userName+";pass->"+this.userPass+";age->"+this.userAge;
* }
* }
*
* 测试调用类:
* package cn.org.jshuwei.j2ee.util.test;
*
* import cn.org.jshuwei.j2ee.util.JsonUtils;
*
* public class Test {
*
* public static void main(String[] args) {
* String str1 = "{userName:'huwei', userAge:23, userPass:'123'}";
* String str2 = "[{'userAge':23,'userName':'huwei','userPass':'123'},{'userAge':32,'userName':'jshuwei','userPass':'pass'},{'userAge':'','userName':'userName','userPass':''}]";
* User u = (User)JsonUtils.json2Object(str1, User.class);
* System.out.println("u-->"+u);
* Object[] objs = JsonUtils.json2ObjectArray(str2);
* for(Object obj : objs){
* User u1 = (User)JsonUtils.json2Object(obj.toString(), User.class);
* System.out.println(u1);
* }
* }
* }
*
* </pre>
*
* @author huwei(jshuwei.org.cn)
*
*/
public class JsonUtils {
/**
* 将一个实体类对象转换成Json数据格式
*
* @param bean
* 需要转换的实体类对象
* @return 转换后的Json格式字符串
*/
public static String beanToJson(Object bean) {
StringBuilder json = new StringBuilder();
json.append("{");
PropertyDescriptor[] props = null;
try {
props = Introspector.getBeanInfo(bean.getClass(), Object.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
}
if (props != null) {
for (int i = 0; i < props.length; i++) {
try {
String name = objectToJson(props[i].getName());
String value = objectToJson(props[i].getReadMethod()
.invoke(bean));
json.append(name);
json.append(":");
json.append(value);
json.append(",");
} catch (Exception e) {
}
}
json.setCharAt(json.length() - 1, '}');
} else {
json.append("}");
}
return json.toString();
}
/**
* 将一个List对象转换成Json数据格式返回
*
* @param list
* 需要进行转换的List对象
* @return 转换后的Json数据格式字符串
*/
public static String listToJson(List<?> list) {
StringBuilder json = new StringBuilder();
json.append("[");
if (list != null && list.size() > 0) {
for (Object obj : list) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
/**
* 将一个对象数组转换成Json数据格式返回
*
* @param array
* 需要进行转换的数组对象
* @return 转换后的Json数据格式字符串
*/
public static String arrayToJson(Object[] array) {
StringBuilder json = new StringBuilder();
json.append("[");
if (array != null && array.length > 0) {
for (Object obj : array) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
/**
* 将一个Map对象转换成Json数据格式返回
*
* @param map
* 需要进行转换的Map对象
* @return 转换后的Json数据格式字符串
*/
public static String mapToJson(Map<?, ?> map) {
StringBuilder json = new StringBuilder();
json.append("{");
if (map != null && map.size() > 0) {
for (Object key : map.keySet()) {
json.append(objectToJson(key));
json.append(":");
json.append(objectToJson(map.get(key)));
json.append(",");
}
json.setCharAt(json.length() - 1, '}');
} else {
json.append("}");
}
return json.toString();
}
/**
* 将一个Set对象转换成Json数据格式返回
*
* @param set
* 需要进行转换的Set对象
* @return 转换后的Json数据格式字符串
*/
public static String setToJson(Set<?> set) {
StringBuilder json = new StringBuilder();
json.append("[");
if (set != null && set.size() > 0) {
for (Object obj : set) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
private static String numberToJson(Number number) {
return number.toString();
}
private static String booleanToJson(Boolean bool) {
return bool.toString();
}
private static String nullToJson() {
return "";
}
private static String stringToJson(String s) {
if (s == null) {
return nullToJson();
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
case '"':
sb.append("\\\"");
break;
case '\\':
sb.append("\\\\");
break;
case '\b':
sb.append("\\b");
break;
case '\f':
sb.append("\\f");
break;
case '\n':
sb.append("\\n");
break;
case '\r':
sb.append("\\r");
break;
case '\t':
sb.append("\\t");
break;
case '/':
sb.append("\\/");
break;
default:
if (ch >= '\u0000' && ch <= '\u001F') {
String ss = Integer.toHexString(ch);
sb.append("\\u");
for (int k = 0; k < 4 - ss.length(); k++) {
sb.append('0');
}
sb.append(ss.toUpperCase());
} else {
sb.append(ch);
}
}
}
return sb.toString();
}
private static String objectToJson(Object obj) {
StringBuilder json = new StringBuilder();
if (obj == null) {
json.append("\"\"");
} else if (obj instanceof Number) {
json.append(numberToJson((Number) obj));
} else if (obj instanceof Boolean) {
json.append(booleanToJson((Boolean) obj));
} else if (obj instanceof String) {
json.append("\"").append(stringToJson(obj.toString())).append("\"");
} else if (obj instanceof Object[]) {
json.append(arrayToJson((Object[]) obj));
} else if (obj instanceof List) {
json.append(listToJson((List<?>) obj));
} else if (obj instanceof Map) {
json.append(mapToJson((Map<?, ?>) obj));
} else if (obj instanceof Set) {
json.append(setToJson((Set<?>) obj));
} else {
json.append(beanToJson(obj));
}
return json.toString();
}
// ============================================================================================
/**
* 将Json格式的字符串转换成指定的对象返回
*
* @param jsonString
* Json格式的字符串
* @param pojoCalss
* 转换后的对象类型
* @return 转换后的对象
*/
@SuppressWarnings("unchecked")
public static Object json2Object(String jsonString, Class pojoCalss) {
Object pojo;
JSONObject jsonObject = JSONObject.fromObject(jsonString);
pojo = JSONObject.toBean(jsonObject, pojoCalss);
return pojo;
}
/**
* 将Json格式的字符串转换成Map<String,Object>对象返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Map<String,Object>对象
*/
@SuppressWarnings("unchecked")
public static Map<String, Object> json2Map(String jsonString) {
JSONObject jsonObject = JSONObject.fromObject(jsonString);
Iterator keyIter = jsonObject.keys();
String key;
Object value;
Map<String, Object> valueMap = new HashMap<String, Object>();
while (keyIter.hasNext()) {
key = (String) keyIter.next();
value = jsonObject.get(key);
valueMap.put(key, value);
}
return valueMap;
}
/**
* 将Json格式的字符串转换成对象数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的对象数组
*/
public static Object[] json2ObjectArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
return jsonArray.toArray();
}
/**
* 将Json格式的字符串转换成指定对象组成的List返回
*
* @param jsonString
* Json格式的字符串
* @param pojoClass
* 转换后的List中对象类型
* @return 转换后的List对象
*/
@SuppressWarnings("unchecked")
public static List json2List(String jsonString, Class pojoClass) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
JSONObject jsonObject;
Object pojoValue;
List list = new ArrayList();
for (int i = 0; i < jsonArray.size(); i++) {
jsonObject = jsonArray.getJSONObject(i);
pojoValue = JSONObject.toBean(jsonObject, pojoClass);
list.add(pojoValue);
}
return list;
}
/**
* 将Json格式的字符串转换成字符串数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的字符串数组
*/
public static String[] json2StringArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
String[] stringArray = new String[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
stringArray[i] = jsonArray.getString(i);
}
return stringArray;
}
/**
* 将Json格式的字符串转换成Long数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Long数组
*/
public static Long[] json2LongArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Long[] longArray = new Long[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
longArray[i] = jsonArray.getLong(i);
}
return longArray;
}
/**
* 将Json格式的字符串转换成Integer数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Integer数组
*/
public static Integer[] json2IntegerArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Integer[] integerArray = new Integer[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
integerArray[i] = jsonArray.getInt(i);
}
return integerArray;
}
/**
* 将Json格式的字符串转换成日期数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @param DataFormat
* 返回的日期格式
* @return 转换后的日期数组
*/
public static Date[] json2DateArray(String jsonString, String DataFormat) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Date[] dateArray = new Date[jsonArray.size()];
String dateString;
Date date;
for (int i = 0; i < jsonArray.size(); i++) {
dateString = jsonArray.getString(i);
date = DateUtil.parseDate(dateString, DataFormat);
dateArray[i] = date;
}
return dateArray;
}
/**
* 将Json格式的字符串转换成Double数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Double数组
*/
public static Double[] json2DoubleArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Double[] doubleArray = new Double[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
doubleArray[i] = jsonArray.getDouble(i);
}
return doubleArray;
}
}
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* Json工具类,实现了实体类和Json数据格式之间的互转功能 使用实例:<br>
*
* <pre>
* User类:
* package cn.org.jshuwei.j2ee.util.test;
*
* public class User {
* private String userName;
* private String userPass;
* private Integer userAge;
*
* public User(){
*
* }
*
* public User(String userName, String userPass, int userAge) {
* super();
* this.userName = userName;
* this.userPass = userPass;
* this.userAge = userAge;
* }
*
* public String getUserName() {
* return userName;
* }
* public void setUserName(String userName) {
* this.userName = userName;
* }
* public String getUserPass() {
* return userPass;
* }
* public void setUserPass(String userPass) {
* this.userPass = userPass;
* }
* public Integer getUserAge() {
* return userAge;
* }
* public void setUserAge(Integer userAge) {
* this.userAge = userAge;
* }
*
* @Override
* public String toString() {
* return "name->"+this.userName+";pass->"+this.userPass+";age->"+this.userAge;
* }
* }
*
* 测试调用类:
* package cn.org.jshuwei.j2ee.util.test;
*
* import cn.org.jshuwei.j2ee.util.JsonUtils;
*
* public class Test {
*
* public static void main(String[] args) {
* String str1 = "{userName:'huwei', userAge:23, userPass:'123'}";
* String str2 = "[{'userAge':23,'userName':'huwei','userPass':'123'},{'userAge':32,'userName':'jshuwei','userPass':'pass'},{'userAge':'','userName':'userName','userPass':''}]";
* User u = (User)JsonUtils.json2Object(str1, User.class);
* System.out.println("u-->"+u);
* Object[] objs = JsonUtils.json2ObjectArray(str2);
* for(Object obj : objs){
* User u1 = (User)JsonUtils.json2Object(obj.toString(), User.class);
* System.out.println(u1);
* }
* }
* }
*
* </pre>
*
* @author huwei(jshuwei.org.cn)
*
*/
public class JsonUtils {
/**
* 将一个实体类对象转换成Json数据格式
*
* @param bean
* 需要转换的实体类对象
* @return 转换后的Json格式字符串
*/
public static String beanToJson(Object bean) {
StringBuilder json = new StringBuilder();
json.append("{");
PropertyDescriptor[] props = null;
try {
props = Introspector.getBeanInfo(bean.getClass(), Object.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
}
if (props != null) {
for (int i = 0; i < props.length; i++) {
try {
String name = objectToJson(props[i].getName());
String value = objectToJson(props[i].getReadMethod()
.invoke(bean));
json.append(name);
json.append(":");
json.append(value);
json.append(",");
} catch (Exception e) {
}
}
json.setCharAt(json.length() - 1, '}');
} else {
json.append("}");
}
return json.toString();
}
/**
* 将一个List对象转换成Json数据格式返回
*
* @param list
* 需要进行转换的List对象
* @return 转换后的Json数据格式字符串
*/
public static String listToJson(List<?> list) {
StringBuilder json = new StringBuilder();
json.append("[");
if (list != null && list.size() > 0) {
for (Object obj : list) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
/**
* 将一个对象数组转换成Json数据格式返回
*
* @param array
* 需要进行转换的数组对象
* @return 转换后的Json数据格式字符串
*/
public static String arrayToJson(Object[] array) {
StringBuilder json = new StringBuilder();
json.append("[");
if (array != null && array.length > 0) {
for (Object obj : array) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
/**
* 将一个Map对象转换成Json数据格式返回
*
* @param map
* 需要进行转换的Map对象
* @return 转换后的Json数据格式字符串
*/
public static String mapToJson(Map<?, ?> map) {
StringBuilder json = new StringBuilder();
json.append("{");
if (map != null && map.size() > 0) {
for (Object key : map.keySet()) {
json.append(objectToJson(key));
json.append(":");
json.append(objectToJson(map.get(key)));
json.append(",");
}
json.setCharAt(json.length() - 1, '}');
} else {
json.append("}");
}
return json.toString();
}
/**
* 将一个Set对象转换成Json数据格式返回
*
* @param set
* 需要进行转换的Set对象
* @return 转换后的Json数据格式字符串
*/
public static String setToJson(Set<?> set) {
StringBuilder json = new StringBuilder();
json.append("[");
if (set != null && set.size() > 0) {
for (Object obj : set) {
json.append(objectToJson(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
private static String numberToJson(Number number) {
return number.toString();
}
private static String booleanToJson(Boolean bool) {
return bool.toString();
}
private static String nullToJson() {
return "";
}
private static String stringToJson(String s) {
if (s == null) {
return nullToJson();
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
case '"':
sb.append("\\\"");
break;
case '\\':
sb.append("\\\\");
break;
case '\b':
sb.append("\\b");
break;
case '\f':
sb.append("\\f");
break;
case '\n':
sb.append("\\n");
break;
case '\r':
sb.append("\\r");
break;
case '\t':
sb.append("\\t");
break;
case '/':
sb.append("\\/");
break;
default:
if (ch >= '\u0000' && ch <= '\u001F') {
String ss = Integer.toHexString(ch);
sb.append("\\u");
for (int k = 0; k < 4 - ss.length(); k++) {
sb.append('0');
}
sb.append(ss.toUpperCase());
} else {
sb.append(ch);
}
}
}
return sb.toString();
}
private static String objectToJson(Object obj) {
StringBuilder json = new StringBuilder();
if (obj == null) {
json.append("\"\"");
} else if (obj instanceof Number) {
json.append(numberToJson((Number) obj));
} else if (obj instanceof Boolean) {
json.append(booleanToJson((Boolean) obj));
} else if (obj instanceof String) {
json.append("\"").append(stringToJson(obj.toString())).append("\"");
} else if (obj instanceof Object[]) {
json.append(arrayToJson((Object[]) obj));
} else if (obj instanceof List) {
json.append(listToJson((List<?>) obj));
} else if (obj instanceof Map) {
json.append(mapToJson((Map<?, ?>) obj));
} else if (obj instanceof Set) {
json.append(setToJson((Set<?>) obj));
} else {
json.append(beanToJson(obj));
}
return json.toString();
}
// ============================================================================================
/**
* 将Json格式的字符串转换成指定的对象返回
*
* @param jsonString
* Json格式的字符串
* @param pojoCalss
* 转换后的对象类型
* @return 转换后的对象
*/
@SuppressWarnings("unchecked")
public static Object json2Object(String jsonString, Class pojoCalss) {
Object pojo;
JSONObject jsonObject = JSONObject.fromObject(jsonString);
pojo = JSONObject.toBean(jsonObject, pojoCalss);
return pojo;
}
/**
* 将Json格式的字符串转换成Map<String,Object>对象返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Map<String,Object>对象
*/
@SuppressWarnings("unchecked")
public static Map<String, Object> json2Map(String jsonString) {
JSONObject jsonObject = JSONObject.fromObject(jsonString);
Iterator keyIter = jsonObject.keys();
String key;
Object value;
Map<String, Object> valueMap = new HashMap<String, Object>();
while (keyIter.hasNext()) {
key = (String) keyIter.next();
value = jsonObject.get(key);
valueMap.put(key, value);
}
return valueMap;
}
/**
* 将Json格式的字符串转换成对象数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的对象数组
*/
public static Object[] json2ObjectArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
return jsonArray.toArray();
}
/**
* 将Json格式的字符串转换成指定对象组成的List返回
*
* @param jsonString
* Json格式的字符串
* @param pojoClass
* 转换后的List中对象类型
* @return 转换后的List对象
*/
@SuppressWarnings("unchecked")
public static List json2List(String jsonString, Class pojoClass) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
JSONObject jsonObject;
Object pojoValue;
List list = new ArrayList();
for (int i = 0; i < jsonArray.size(); i++) {
jsonObject = jsonArray.getJSONObject(i);
pojoValue = JSONObject.toBean(jsonObject, pojoClass);
list.add(pojoValue);
}
return list;
}
/**
* 将Json格式的字符串转换成字符串数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的字符串数组
*/
public static String[] json2StringArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
String[] stringArray = new String[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
stringArray[i] = jsonArray.getString(i);
}
return stringArray;
}
/**
* 将Json格式的字符串转换成Long数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Long数组
*/
public static Long[] json2LongArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Long[] longArray = new Long[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
longArray[i] = jsonArray.getLong(i);
}
return longArray;
}
/**
* 将Json格式的字符串转换成Integer数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Integer数组
*/
public static Integer[] json2IntegerArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Integer[] integerArray = new Integer[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
integerArray[i] = jsonArray.getInt(i);
}
return integerArray;
}
/**
* 将Json格式的字符串转换成日期数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @param DataFormat
* 返回的日期格式
* @return 转换后的日期数组
*/
public static Date[] json2DateArray(String jsonString, String DataFormat) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Date[] dateArray = new Date[jsonArray.size()];
String dateString;
Date date;
for (int i = 0; i < jsonArray.size(); i++) {
dateString = jsonArray.getString(i);
date = DateUtil.parseDate(dateString, DataFormat);
dateArray[i] = date;
}
return dateArray;
}
/**
* 将Json格式的字符串转换成Double数组返回
*
* @param jsonString
* 需要进行转换的Json格式字符串
* @return 转换后的Double数组
*/
public static Double[] json2DoubleArray(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
Double[] doubleArray = new Double[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
doubleArray[i] = jsonArray.getDouble(i);
}
return doubleArray;
}
}
2.hibernate操作
代码
package cn.org.jshuwei.j2ee.util;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
*
* Hibernate操作的工具类
*
* @author huwei(jshuwei.org.cn)
* @since 1.0
*
*/
public class HbnUtil {
private static SessionFactory sf;
/**
* 得到SessionFactory
*
* @since 1.0
* @return 返回SessionFactory
*/
public static SessionFactory getSessionFactory() {
if (sf == null || sf.isClosed()) {
try {
sf = new Configuration().configure().buildSessionFactory();
} catch (HibernateException e) {
e.printStackTrace();
}
}
return sf;
}
/**
* 得到Session
*
* @since 1.0
* @return 返回Session
*/
public static Session getSession() {
getSessionFactory();
return sf.openSession();
}
/**
* 释放SessionFactory
*
* @since 1.0
*/
public static void releaseSessionFactory() {
if (sf != null && !sf.isClosed()) {
sf.close();
}
}
/**
* 保存对象
*
* @since 1.0
* @param obj
* 需要保存的对象
*/
public static Serializable add(Object obj) {
Session session = null;
Serializable ret = null;
try {
session = getSession();
session.beginTransaction();
ret = session.save(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
return ret;
}
/**
* 删除对象
*
* @since 1.0
* @param obj
* 需要删除的对象
*/
public static void delete(Object obj) {
Session session = null;
try {
session = getSession();
session.beginTransaction();
session.delete(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
}
/**
* 更新对象
*
* @since 1.0
* @param obj
* 需要更新的对象
*/
public static void update(Object obj) {
Session session = null;
try {
session = getSession();
session.beginTransaction();
session.update(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
}
/**
* 查找对象
*
* @since 1.0
* @param clazz 需要查找的对象类型
* @param id
* 需要查找的对象的id
*/
public static Object find(Class clazz,Serializable id) {
Session session = null;
Object obj=null;
try {
session = getSession();
obj=session.get(clazz, id);
} catch (HibernateException e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
return obj;
}
}
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
*
* Hibernate操作的工具类
*
* @author huwei(jshuwei.org.cn)
* @since 1.0
*
*/
public class HbnUtil {
private static SessionFactory sf;
/**
* 得到SessionFactory
*
* @since 1.0
* @return 返回SessionFactory
*/
public static SessionFactory getSessionFactory() {
if (sf == null || sf.isClosed()) {
try {
sf = new Configuration().configure().buildSessionFactory();
} catch (HibernateException e) {
e.printStackTrace();
}
}
return sf;
}
/**
* 得到Session
*
* @since 1.0
* @return 返回Session
*/
public static Session getSession() {
getSessionFactory();
return sf.openSession();
}
/**
* 释放SessionFactory
*
* @since 1.0
*/
public static void releaseSessionFactory() {
if (sf != null && !sf.isClosed()) {
sf.close();
}
}
/**
* 保存对象
*
* @since 1.0
* @param obj
* 需要保存的对象
*/
public static Serializable add(Object obj) {
Session session = null;
Serializable ret = null;
try {
session = getSession();
session.beginTransaction();
ret = session.save(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
return ret;
}
/**
* 删除对象
*
* @since 1.0
* @param obj
* 需要删除的对象
*/
public static void delete(Object obj) {
Session session = null;
try {
session = getSession();
session.beginTransaction();
session.delete(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
}
/**
* 更新对象
*
* @since 1.0
* @param obj
* 需要更新的对象
*/
public static void update(Object obj) {
Session session = null;
try {
session = getSession();
session.beginTransaction();
session.update(obj);
session.getTransaction().commit();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
}
/**
* 查找对象
*
* @since 1.0
* @param clazz 需要查找的对象类型
* @param id
* 需要查找的对象的id
*/
public static Object find(Class clazz,Serializable id) {
Session session = null;
Object obj=null;
try {
session = getSession();
obj=session.get(clazz, id);
} catch (HibernateException e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
releaseSessionFactory();
}
return obj;
}
}
3.数组操作类
代码
package cn.org.jshuwei.j2ee.util;
/**
*
* 数组操作的工具类(以int型数组为例)
*
* <b>排序算法的分类如下:</b><br /> 1.插入排序(直接插入排序、折半插入排序、希尔排序); <br />
* 2.交换排序(冒泡泡排序、快速排序);<br /> 3.选择排序(直接选择排序、堆排序);<br /> 4.归并排序; <br /> 5.基数排序。<br
* />
*
* <b>关于排序方法的选择:</b><br /> (1)若n较小(如n≤50),可采用直接插入或直接选择排序。<br />
* (2)若文件初始状态基本有序(指正序),则应选用直接插人、冒泡或随机的快速排序为宜;<br />
* (3)若n较大,则应采用时间复杂度为O(nlgn)的排序方法:快速排序、堆排序或归并排序。<br />
*
* @author huwei(jshuwei.org.cn)
* @since 1.1
*
*/
public class ArrayUtil {
/**
* 交换数组中两元素
*
* @since 1.1
* @param ints
* 需要进行交换操作的数组
* @param x
* 数组中的位置1
* @param y
* 数组中的位置2
* @return 交换后的数组
*/
public static int[] swap(int[] ints, int x, int y) {
int temp = ints[x];
ints[x] = ints[y];
ints[y] = temp;
return ints;
}
/**
* 冒泡排序 方法:相邻两元素进行比较 性能:比较次数O(n^2),n^2/2;交换次数O(n^2),n^2/4
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] bubbleSort(int[] source) {
for (int i = 1; i < source.length; i++) {
for (int j = 0; j < i; j++) {
if (source[j] > source[j + 1]) {
swap(source, j, j + 1);
}
}
}
return source;
}
/**
* 直接选择排序法 方法:每一趟从待排序的数据元素中选出最小(或最大)的一个元素, 顺序放在已排好序的数列的最后,直到全部待排序的数据元素排完。
* 性能:比较次数O(n^2),n^2/2 交换次数O(n),n
* 交换次数比冒泡排序少多了,由于交换所需CPU时间比比较所需的CUP时间多,所以选择排序比冒泡排序快。
* 但是N比较大时,比较所需的CPU时间占主要地位,所以这时的性能和冒泡排序差不太多,但毫无疑问肯定要快些。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] selectSort(int[] source) {
for (int i = 0; i < source.length; i++) {
for (int j = i + 1; j < source.length; j++) {
if (source[i] > source[j]) {
swap(source, i, j);
}
}
}
return source;
}
/**
* 插入排序 方法:将一个记录插入到已排好序的有序表(有可能是空表)中,从而得到一个新的记录数增1的有序表。 性能:比较次数O(n^2),n^2/4
* 复制次数O(n),n^2/4 比较次数是前两者的一般,而复制所需的CPU时间较交换少,所以性能上比冒泡排序提高一倍多,而比选择排序也要快。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] insertSort(int[] source) {
for (int i = 1; i < source.length; i++) {
for (int j = i; (j > 0) && (source[j] < source[j - 1]); j--) {
swap(source, j, j - 1);
}
}
return source;
}
/**
* 快速排序 快速排序使用分治法(Divide and conquer)策略来把一个序列(list)分为两个子序列(sub-lists)。 步骤为:
* 1. 从数列中挑出一个元素,称为 "基准"(pivot), 2.
* 重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面
* (相同的数可以到任一边)。在这个分割之后,该基准是它的最后位置。这个称为分割(partition)操作。 3.
* 递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序。
* 递回的最底部情形,是数列的大小是零或一,也就是永远都已经被排序好了
* 。虽然一直递回下去,但是这个算法总会结束,因为在每次的迭代(iteration)中,它至少会把一个元素摆到它最后的位置去。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] quickSort(int[] source) {
return qsort(source, 0, source.length - 1);
}
/**
* 快速排序的具体实现,排正序
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @param low
* 开始低位
* @param high
* 结束高位
* @return 排序后的数组
*/
private static int[] qsort(int source[], int low, int high) {
int i, j, x;
if (low < high) {
i = low;
j = high;
x = source[i];
while (i < j) {
while (i < j && source[j] > x) {
j--;
}
if (i < j) {
source[i] = source[j];
i++;
}
while (i < j && source[i] < x) {
i++;
}
if (i < j) {
source[j] = source[i];
j--;
}
}
source[i] = x;
qsort(source, low, i - 1);
qsort(source, i + 1, high);
}
return source;
}
/**
* 二分法查找 查找线性表必须是有序列表
*
* @since 1.1
* @param source
* 需要进行查找操作的数组
* @param key
* 需要查找的值
* @return 需要查找的值在数组中的位置,若未查到则返回-1
*/
public int binarySearch(int[] source, int key) {
int low = 0, high = source.length - 1, mid;
while (low <= high) {
mid = (low + high) >>> 1;
if (key == source[mid]) {
return mid;
} else if (key < source[mid]) {
high = mid - 1;
} else {
low = mid + 1;
}
}
return -1;
}
/**
* 反转数组
*
* @since 1.1
* @param source
* 需要进行反转操作的数组
* @return 反转后的数组
*/
public static int[] reverse(int[] source) {
int length = source.length;
int temp = 0;
for (int i = 0; i < length / 2; i++) {
temp = source[i];
source[i] = source[length - 1 - i];
source[length - 1 - i] = temp;
}
return source;
}
}
/**
*
* 数组操作的工具类(以int型数组为例)
*
* <b>排序算法的分类如下:</b><br /> 1.插入排序(直接插入排序、折半插入排序、希尔排序); <br />
* 2.交换排序(冒泡泡排序、快速排序);<br /> 3.选择排序(直接选择排序、堆排序);<br /> 4.归并排序; <br /> 5.基数排序。<br
* />
*
* <b>关于排序方法的选择:</b><br /> (1)若n较小(如n≤50),可采用直接插入或直接选择排序。<br />
* (2)若文件初始状态基本有序(指正序),则应选用直接插人、冒泡或随机的快速排序为宜;<br />
* (3)若n较大,则应采用时间复杂度为O(nlgn)的排序方法:快速排序、堆排序或归并排序。<br />
*
* @author huwei(jshuwei.org.cn)
* @since 1.1
*
*/
public class ArrayUtil {
/**
* 交换数组中两元素
*
* @since 1.1
* @param ints
* 需要进行交换操作的数组
* @param x
* 数组中的位置1
* @param y
* 数组中的位置2
* @return 交换后的数组
*/
public static int[] swap(int[] ints, int x, int y) {
int temp = ints[x];
ints[x] = ints[y];
ints[y] = temp;
return ints;
}
/**
* 冒泡排序 方法:相邻两元素进行比较 性能:比较次数O(n^2),n^2/2;交换次数O(n^2),n^2/4
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] bubbleSort(int[] source) {
for (int i = 1; i < source.length; i++) {
for (int j = 0; j < i; j++) {
if (source[j] > source[j + 1]) {
swap(source, j, j + 1);
}
}
}
return source;
}
/**
* 直接选择排序法 方法:每一趟从待排序的数据元素中选出最小(或最大)的一个元素, 顺序放在已排好序的数列的最后,直到全部待排序的数据元素排完。
* 性能:比较次数O(n^2),n^2/2 交换次数O(n),n
* 交换次数比冒泡排序少多了,由于交换所需CPU时间比比较所需的CUP时间多,所以选择排序比冒泡排序快。
* 但是N比较大时,比较所需的CPU时间占主要地位,所以这时的性能和冒泡排序差不太多,但毫无疑问肯定要快些。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] selectSort(int[] source) {
for (int i = 0; i < source.length; i++) {
for (int j = i + 1; j < source.length; j++) {
if (source[i] > source[j]) {
swap(source, i, j);
}
}
}
return source;
}
/**
* 插入排序 方法:将一个记录插入到已排好序的有序表(有可能是空表)中,从而得到一个新的记录数增1的有序表。 性能:比较次数O(n^2),n^2/4
* 复制次数O(n),n^2/4 比较次数是前两者的一般,而复制所需的CPU时间较交换少,所以性能上比冒泡排序提高一倍多,而比选择排序也要快。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] insertSort(int[] source) {
for (int i = 1; i < source.length; i++) {
for (int j = i; (j > 0) && (source[j] < source[j - 1]); j--) {
swap(source, j, j - 1);
}
}
return source;
}
/**
* 快速排序 快速排序使用分治法(Divide and conquer)策略来把一个序列(list)分为两个子序列(sub-lists)。 步骤为:
* 1. 从数列中挑出一个元素,称为 "基准"(pivot), 2.
* 重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面
* (相同的数可以到任一边)。在这个分割之后,该基准是它的最后位置。这个称为分割(partition)操作。 3.
* 递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序。
* 递回的最底部情形,是数列的大小是零或一,也就是永远都已经被排序好了
* 。虽然一直递回下去,但是这个算法总会结束,因为在每次的迭代(iteration)中,它至少会把一个元素摆到它最后的位置去。
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @return 排序后的数组
*/
public static int[] quickSort(int[] source) {
return qsort(source, 0, source.length - 1);
}
/**
* 快速排序的具体实现,排正序
*
* @since 1.1
* @param source
* 需要进行排序操作的数组
* @param low
* 开始低位
* @param high
* 结束高位
* @return 排序后的数组
*/
private static int[] qsort(int source[], int low, int high) {
int i, j, x;
if (low < high) {
i = low;
j = high;
x = source[i];
while (i < j) {
while (i < j && source[j] > x) {
j--;
}
if (i < j) {
source[i] = source[j];
i++;
}
while (i < j && source[i] < x) {
i++;
}
if (i < j) {
source[j] = source[i];
j--;
}
}
source[i] = x;
qsort(source, low, i - 1);
qsort(source, i + 1, high);
}
return source;
}
/**
* 二分法查找 查找线性表必须是有序列表
*
* @since 1.1
* @param source
* 需要进行查找操作的数组
* @param key
* 需要查找的值
* @return 需要查找的值在数组中的位置,若未查到则返回-1
*/
public int binarySearch(int[] source, int key) {
int low = 0, high = source.length - 1, mid;
while (low <= high) {
mid = (low + high) >>> 1;
if (key == source[mid]) {
return mid;
} else if (key < source[mid]) {
high = mid - 1;
} else {
low = mid + 1;
}
}
return -1;
}
/**
* 反转数组
*
* @since 1.1
* @param source
* 需要进行反转操作的数组
* @return 反转后的数组
*/
public static int[] reverse(int[] source) {
int length = source.length;
int temp = 0;
for (int i = 0; i < length / 2; i++) {
temp = source[i];
source[i] = source[length - 1 - i];
source[length - 1 - i] = temp;
}
return source;
}
}
4.文件打包解包处理类
代码
package cn.org.jshuwei.j2ee.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipOutputStream;
/**
* 文件压缩解压工具类
*
* @author huwei(jshuwei.org.cn)
* @since 1.2
*
*/
public class ZipUtil {
/**
* 压缩ZIP文件,将baseDirName目录下的所有文件压缩到targetFileName.ZIP文件中
*
* @param baseDirName
* 需要压缩的文件的跟目录
* @param targetFileName
* 压缩有生成的文件名
*/
public static void zipFile(String baseDirName, String targetFileName) {
if (baseDirName == null) {
return;
}
File file = new File(baseDirName);
if (!file.exists()) {
return;
}
String baseDirPath = file.getAbsolutePath();
File targetFile = new File(targetFileName);
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
targetFile));
if (file.isFile()) {
fileToZip(baseDirPath, file, out);
} else {
dirToZip(baseDirPath, file, out);
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 解压缩ZIP文件,将ZIP文件里的内容解压到targetBaseDirName目录下
*
* @param zipFileName
* 待解压缩的ZIP文件名
* @param targetBaseDirName
* 目标目录
*/
@SuppressWarnings("unchecked")
public static void unzipFile(String zipFileName, String targetBaseDirName) {
if (!targetBaseDirName.endsWith(File.separator)) {
targetBaseDirName += File.separator;
}
try {
ZipFile zipFile = new ZipFile(zipFileName);
ZipEntry entry = null;
String entryName = null;
String targetFileName = null;
byte[] buffer = new byte[4096];
int bytes_read;
Enumeration entrys = zipFile.getEntries();//.entries();
while (entrys.hasMoreElements()) {
entry = (ZipEntry) entrys.nextElement();
entryName = entry.getName();
targetFileName = targetBaseDirName + entryName;
if (entry.isDirectory()) {
new File(targetFileName).mkdirs();
continue;
} else {
new File(targetFileName).getParentFile().mkdirs();
}
File targetFile = new File(targetFileName);
FileOutputStream os = new FileOutputStream(targetFile);
InputStream is = zipFile.getInputStream(entry);
while ((bytes_read = is.read(buffer)) != -1) {
os.write(buffer, 0, bytes_read);
}
os.close();
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void dirToZip(String baseDirPath, File dir,
ZipOutputStream out) {
if (dir.isDirectory()) {
File[] files = dir.listFiles();
if (files.length == 0) {
ZipEntry entry = new ZipEntry(getEntryName(baseDirPath, dir));
try {
out.putNextEntry(entry);
out.closeEntry();
} catch (IOException e) {
e.printStackTrace();
}
return;
}
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
fileToZip(baseDirPath, files[i], out);
} else {
dirToZip(baseDirPath, files[i], out);
}
}
}
}
private static void fileToZip(String baseDirPath, File file,
ZipOutputStream out) {
FileInputStream in = null;
ZipEntry entry = null;
byte[] buffer = new byte[4096];
int bytes_read;
if (file.isFile()) {
try {
in = new FileInputStream(file);
entry = new ZipEntry(getEntryName(baseDirPath, file));
out.putNextEntry(entry);
while ((bytes_read = in.read(buffer)) != -1) {
out.write(buffer, 0, bytes_read);
}
out.closeEntry();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static String getEntryName(String baseDirPath, File file) {
if (!baseDirPath.endsWith(File.separator)) {
baseDirPath += File.separator;
}
String filePath = file.getAbsolutePath();
if (file.isDirectory()) {
filePath += "/";
}
int index = filePath.indexOf(baseDirPath);
return filePath.substring(index + baseDirPath.length());
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipOutputStream;
/**
* 文件压缩解压工具类
*
* @author huwei(jshuwei.org.cn)
* @since 1.2
*
*/
public class ZipUtil {
/**
* 压缩ZIP文件,将baseDirName目录下的所有文件压缩到targetFileName.ZIP文件中
*
* @param baseDirName
* 需要压缩的文件的跟目录
* @param targetFileName
* 压缩有生成的文件名
*/
public static void zipFile(String baseDirName, String targetFileName) {
if (baseDirName == null) {
return;
}
File file = new File(baseDirName);
if (!file.exists()) {
return;
}
String baseDirPath = file.getAbsolutePath();
File targetFile = new File(targetFileName);
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
targetFile));
if (file.isFile()) {
fileToZip(baseDirPath, file, out);
} else {
dirToZip(baseDirPath, file, out);
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 解压缩ZIP文件,将ZIP文件里的内容解压到targetBaseDirName目录下
*
* @param zipFileName
* 待解压缩的ZIP文件名
* @param targetBaseDirName
* 目标目录
*/
@SuppressWarnings("unchecked")
public static void unzipFile(String zipFileName, String targetBaseDirName) {
if (!targetBaseDirName.endsWith(File.separator)) {
targetBaseDirName += File.separator;
}
try {
ZipFile zipFile = new ZipFile(zipFileName);
ZipEntry entry = null;
String entryName = null;
String targetFileName = null;
byte[] buffer = new byte[4096];
int bytes_read;
Enumeration entrys = zipFile.getEntries();//.entries();
while (entrys.hasMoreElements()) {
entry = (ZipEntry) entrys.nextElement();
entryName = entry.getName();
targetFileName = targetBaseDirName + entryName;
if (entry.isDirectory()) {
new File(targetFileName).mkdirs();
continue;
} else {
new File(targetFileName).getParentFile().mkdirs();
}
File targetFile = new File(targetFileName);
FileOutputStream os = new FileOutputStream(targetFile);
InputStream is = zipFile.getInputStream(entry);
while ((bytes_read = is.read(buffer)) != -1) {
os.write(buffer, 0, bytes_read);
}
os.close();
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void dirToZip(String baseDirPath, File dir,
ZipOutputStream out) {
if (dir.isDirectory()) {
File[] files = dir.listFiles();
if (files.length == 0) {
ZipEntry entry = new ZipEntry(getEntryName(baseDirPath, dir));
try {
out.putNextEntry(entry);
out.closeEntry();
} catch (IOException e) {
e.printStackTrace();
}
return;
}
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
fileToZip(baseDirPath, files[i], out);
} else {
dirToZip(baseDirPath, files[i], out);
}
}
}
}
private static void fileToZip(String baseDirPath, File file,
ZipOutputStream out) {
FileInputStream in = null;
ZipEntry entry = null;
byte[] buffer = new byte[4096];
int bytes_read;
if (file.isFile()) {
try {
in = new FileInputStream(file);
entry = new ZipEntry(getEntryName(baseDirPath, file));
out.putNextEntry(entry);
while ((bytes_read = in.read(buffer)) != -1) {
out.write(buffer, 0, bytes_read);
}
out.closeEntry();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static String getEntryName(String baseDirPath, File file) {
if (!baseDirPath.endsWith(File.separator)) {
baseDirPath += File.separator;
}
String filePath = file.getAbsolutePath();
if (file.isDirectory()) {
filePath += "/";
}
int index = filePath.indexOf(baseDirPath);
return filePath.substring(index + baseDirPath.length());
}
}
5.文件操作类
代码
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
/**
* 文件操作工具类
*
* @author jshuwei.org.cn" target="_blank">huwei(jsjshuwei.org.cn" target="_blank">huwei.org.cn)
* @since 1.2
*
*/
public class FileUtil {
/**
* 将字节流转换成字符串返回
*
* @param is
* 输入流
* @return 字符串
*/
public static String readFileByLines(InputStream is) {
BufferedReader reader = null;
StringBuffer sb = new StringBuffer();
try {
reader = new BufferedReader(new InputStreamReader(is));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
sb.append(tempString + "\n");
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return sb.toString();
}
/**
* 将文件一行一行的读成List返回
*
* @param file
* 需要读取的文件
* @return 文件的一行就是一个List的Item的返回
*/
public static List<String> readFileToList(File file) {
BufferedReader reader = null;
List<String> list = new ArrayList<String>();
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
list.add(tempString);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return list;
}
/**
* 将文件按照一定的编码方式一行一行的读成List返回
*
* @param file
* 需要读取的文件
* @param encodType
* 字符编码
* @return 文件的一行就是一个List的Item的返回
*/
public static List<String> readFileToList(File file, String encodType) {
BufferedReader reader = null;
List<String> list = new ArrayList<String>();
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file), encodType));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
if (!(tempString.charAt(0) >= 'a' && tempString.charAt(0) <= 'z'))
tempString = tempString.substring(1);
list.add(tempString);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return list;
}
/**
* 将指定的字符串内容以指定的方式写入到指定的文件中
*
* @param file
* 需要写人的文件
* @param content
* 需要写入的内容
* @param flag
* 是否追加写入
*/
public static void writeFile(File file, String content, Boolean flag) {
try {
if (!file.exists())
file.createNewFile();
FileWriter writer = new FileWriter(file, flag);
writer.write(content);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 将指定的字符串内容以指定的方式及编码写入到指定的文件中
*
* @param file
* 需要写人的文件
* @param content
* 需要写入的内容
* @param flag
* 是否追加写入
* @param encodType
* 文件编码
*/
public static void writeFile(File file, String content, Boolean flag,
String encodType) {
try {
FileOutputStream writerStream = new FileOutputStream(file, flag);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
writerStream, encodType));
writer.write(content);
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 拷贝文件夹
*
* @param oldPath
* 源目录
* @param newPath
* 目标目录
*/
public static void copyFolder(String oldPath, String newPath) {
try {
(new File(newPath)).mkdirs();
File a = new File(oldPath);
String[] file = a.list();
File temp = null;
for (int i = 0; i < file.length; i++) {
if (oldPath.endsWith(File.separator)) {
temp = new File(oldPath + file[i]);
} else {
temp = new File(oldPath + File.separator + file[i]);
}
if (temp.isFile()) {
FileInputStream input = new FileInputStream(temp);
FileOutputStream output = new FileOutputStream(newPath
+ "/" + (temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ((len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
}
if (temp.isDirectory()) {
copyFolder(oldPath + "/" + file[i], newPath + "/" + file[i]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 将文件重命名
*
* @param oldName
* 源文件名
* @param newName
* 新文件名
*/
public static void reName(String oldName, String newName) {
File oldF = new File(oldName);
File newF = new File(newName);
oldF.renameTo(newF);
}
/**
* 将一个文件列表文件中所有文件拷贝到指定目录中
*
* @param listFile
* 包含需要拷贝的文件的列表的文件,每个文件写在一行
* @param targetFloder
* 目标目录
*/
public static void copyFilesFromList(String listFile, String targetFloder) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(listFile));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
copyFile(tempString, targetFloder);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/**
* 拷贝文件
*
* @param oldPath
* 源文件
* @param newPath
* 目标文件
*/
public static void copyFile(String oldPath, String newPath) {
try {
File temp = new File(oldPath);
FileInputStream input = new FileInputStream(temp);
FileOutputStream output = new FileOutputStream(newPath + "/"
+ (temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ((len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除文件列表
*
* @param files
* 需要删除的文件/文件夹列表
* @return 删除成功true,否则返回false
*/
public static boolean deleteFiles(List<String> files) {
boolean flag = true;
for (String file : files) {
flag = delete(file);
if (!flag)
break;
}
return flag;
}
/**
* 删除文件或文件夹
*
* @param fileName
* 要删除的文件名
* @return 删除成功返回true,否则返回false
*/
public static boolean delete(String fileName) {
File file = new File(fileName);
if (!file.exists()) {
return false;
} else {
if (file.isFile())
return deleteFile(fileName);
else
return deleteDirectory(fileName);
}
}
/**
* 删除文件
*
* @param fileName
* 要删除的文件的文件名
* @return 删除成功返回true,否则返回false
*/
public static boolean deleteFile(String fileName) {
File file = new File(fileName);
if (file.exists() && file.isFile())
return file.delete();
return false;
}
/**
* 删除目录及目录下的文件
*
* @param dir
* 要删除的目录路径
* @return 删除成功返回true,否则返回false
*/
public static boolean deleteDirectory(String dir) {
if (!dir.endsWith(File.separator))
dir = dir + File.separator;
File dirFile = new File(dir);
if ((!dirFile.exists()) || (!dirFile.isDirectory()))
return false;
boolean flag = true;
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
flag = deleteFile(files[i].getAbsolutePath());
if (!flag)
break;
} else if (files[i].isDirectory()) {
flag = deleteDirectory(files[i].getAbsolutePath());
if (!flag)
break;
}
}
if (!flag) {
return false;
}
return dirFile.delete();
}
}
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
/**
* 文件操作工具类
*
* @author jshuwei.org.cn" target="_blank">huwei(jsjshuwei.org.cn" target="_blank">huwei.org.cn)
* @since 1.2
*
*/
public class FileUtil {
/**
* 将字节流转换成字符串返回
*
* @param is
* 输入流
* @return 字符串
*/
public static String readFileByLines(InputStream is) {
BufferedReader reader = null;
StringBuffer sb = new StringBuffer();
try {
reader = new BufferedReader(new InputStreamReader(is));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
sb.append(tempString + "\n");
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return sb.toString();
}
/**
* 将文件一行一行的读成List返回
*
* @param file
* 需要读取的文件
* @return 文件的一行就是一个List的Item的返回
*/
public static List<String> readFileToList(File file) {
BufferedReader reader = null;
List<String> list = new ArrayList<String>();
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
list.add(tempString);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return list;
}
/**
* 将文件按照一定的编码方式一行一行的读成List返回
*
* @param file
* 需要读取的文件
* @param encodType
* 字符编码
* @return 文件的一行就是一个List的Item的返回
*/
public static List<String> readFileToList(File file, String encodType) {
BufferedReader reader = null;
List<String> list = new ArrayList<String>();
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file), encodType));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
if (!(tempString.charAt(0) >= 'a' && tempString.charAt(0) <= 'z'))
tempString = tempString.substring(1);
list.add(tempString);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return list;
}
/**
* 将指定的字符串内容以指定的方式写入到指定的文件中
*
* @param file
* 需要写人的文件
* @param content
* 需要写入的内容
* @param flag
* 是否追加写入
*/
public static void writeFile(File file, String content, Boolean flag) {
try {
if (!file.exists())
file.createNewFile();
FileWriter writer = new FileWriter(file, flag);
writer.write(content);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 将指定的字符串内容以指定的方式及编码写入到指定的文件中
*
* @param file
* 需要写人的文件
* @param content
* 需要写入的内容
* @param flag
* 是否追加写入
* @param encodType
* 文件编码
*/
public static void writeFile(File file, String content, Boolean flag,
String encodType) {
try {
FileOutputStream writerStream = new FileOutputStream(file, flag);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
writerStream, encodType));
writer.write(content);
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 拷贝文件夹
*
* @param oldPath
* 源目录
* @param newPath
* 目标目录
*/
public static void copyFolder(String oldPath, String newPath) {
try {
(new File(newPath)).mkdirs();
File a = new File(oldPath);
String[] file = a.list();
File temp = null;
for (int i = 0; i < file.length; i++) {
if (oldPath.endsWith(File.separator)) {
temp = new File(oldPath + file[i]);
} else {
temp = new File(oldPath + File.separator + file[i]);
}
if (temp.isFile()) {
FileInputStream input = new FileInputStream(temp);
FileOutputStream output = new FileOutputStream(newPath
+ "/" + (temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ((len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
}
if (temp.isDirectory()) {
copyFolder(oldPath + "/" + file[i], newPath + "/" + file[i]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 将文件重命名
*
* @param oldName
* 源文件名
* @param newName
* 新文件名
*/
public static void reName(String oldName, String newName) {
File oldF = new File(oldName);
File newF = new File(newName);
oldF.renameTo(newF);
}
/**
* 将一个文件列表文件中所有文件拷贝到指定目录中
*
* @param listFile
* 包含需要拷贝的文件的列表的文件,每个文件写在一行
* @param targetFloder
* 目标目录
*/
public static void copyFilesFromList(String listFile, String targetFloder) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(listFile));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
copyFile(tempString, targetFloder);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/**
* 拷贝文件
*
* @param oldPath
* 源文件
* @param newPath
* 目标文件
*/
public static void copyFile(String oldPath, String newPath) {
try {
File temp = new File(oldPath);
FileInputStream input = new FileInputStream(temp);
FileOutputStream output = new FileOutputStream(newPath + "/"
+ (temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ((len = input.read(b)) != -1) {
output.write(b, 0, len);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除文件列表
*
* @param files
* 需要删除的文件/文件夹列表
* @return 删除成功true,否则返回false
*/
public static boolean deleteFiles(List<String> files) {
boolean flag = true;
for (String file : files) {
flag = delete(file);
if (!flag)
break;
}
return flag;
}
/**
* 删除文件或文件夹
*
* @param fileName
* 要删除的文件名
* @return 删除成功返回true,否则返回false
*/
public static boolean delete(String fileName) {
File file = new File(fileName);
if (!file.exists()) {
return false;
} else {
if (file.isFile())
return deleteFile(fileName);
else
return deleteDirectory(fileName);
}
}
/**
* 删除文件
*
* @param fileName
* 要删除的文件的文件名
* @return 删除成功返回true,否则返回false
*/
public static boolean deleteFile(String fileName) {
File file = new File(fileName);
if (file.exists() && file.isFile())
return file.delete();
return false;
}
/**
* 删除目录及目录下的文件
*
* @param dir
* 要删除的目录路径
* @return 删除成功返回true,否则返回false
*/
public static boolean deleteDirectory(String dir) {
if (!dir.endsWith(File.separator))
dir = dir + File.separator;
File dirFile = new File(dir);
if ((!dirFile.exists()) || (!dirFile.isDirectory()))
return false;
boolean flag = true;
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
flag = deleteFile(files[i].getAbsolutePath());
if (!flag)
break;
} else if (files[i].isDirectory()) {
flag = deleteDirectory(files[i].getAbsolutePath());
if (!flag)
break;
}
}
if (!flag) {
return false;
}
return dirFile.delete();
}
}
6.字符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YYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZGLHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJXY";
/**
* 将一字符串转换成拼音首字母
*
* @since 1.1
* @param strText
* 字符串
* @return 字符串对应的拼音首字母
*/
public static String getFirstPY(String strText) {
if (strText == null || strText.trim().length() == 0)
return "";
String ret = "";
for (int i = 0; i < strText.length(); i++) {
char ch = strText.charAt(i);
if ('\u4E00' <= ch && '\u9FA5' >= ch)
ret = ret + strChineseFirstPY.charAt(ch - 19968);
else
ret = ret + ch;
}
return ret;
}
/**
* 替换字符串
*
* @since 1.1
* @param strSc
* 需要进行替换的字符串
* @param oldStr
* 源字符串
* @param newStr
* 替换后的字符串
* @return 替换后对应的字符串
*/
public static String replace(String strSc, String oldStr, String newStr) {
String ret = strSc;
if (ret != null && oldStr != null && newStr != null) {
ret = strSc.replaceAll(oldStr, newStr);
}
return ret;
}
/**
* 替换字符串,修复java.lang.String类的replaceAll方法时第一参数是字符串常量正则时(如:"address".
* replaceAll("dd","$");)的抛出异常:java.lang.StringIndexOutOfBoundsException:
* String index out of range: 1的问题。
*
* @since 1.2
* @param strSc
* 需要进行替换的字符串
* @param oldStr
* 源字符串
* @param newStr
* 替换后的字符串
* @return 替换后对应的字符串
*/
public static String replaceAll(String strSc, String oldStr, String newStr) {
int i = -1;
while ((i = strSc.indexOf(oldStr)) != -1) {
strSc = new StringBuffer(strSc.substring(0, i)).append(newStr)
.append(strSc.substring(i + oldStr.length())).toString();
}
return strSc;
}
/**
* 将字符串转换成HTML格式的字符串
*
* @since 1.1
* @param str
* 需要进行转换的字符串
* @return 转换后的字符串
*/
public static String toHtml(String str) {
String html = str;
if (str == null || str.length() == 0) {
return "";
} else {
html = replace(html, "&", "&");
html = replace(html, "<", "<");
html = replace(html, ">", ">");
html = replace(html, "\r\n", "\n");
html = replace(html, "\n", "<br>\n");
html = replace(html, "\"", """);
html = replace(html, " ", " ");
return html;
}
}
/**
* 将HTML格式的字符串转换成常规显示的字符串
*
* @since 1.1
* @param str
* 需要进行转换的字符串
* @return 转换后的字符串
*/
public static String toText(String str) {
String text = str;
if (str == null || str.length() == 0) {
return "";
} else {
text = replace(text, "&", "&");
text = replace(text, "<", "<");
text = replace(text, ">", ">");
text = replace(text, "<br>\n", "\n");
text = replace(text, "<br>", "\n");
text = replace(text, """, "\"");
text = replace(text, " ", " ");
return text;
}
}
/**
* 将一字符串数组以某特定的字符串作为分隔来变成字符串
*
* @since 1.0
* @param strs
* 字符串数组
* @param token
* 分隔字符串
* @return 以token为分隔的字符串
*/
public static String join(String[] strs, String token) {
if (strs == null)
return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < strs.length; i++) {
if (i != 0)
sb.append(token);
sb.append(strs[i]);
}
return sb.toString();
}
/**
* 将一字符串以某特定的字符串作为分隔来变成字符串数组
*
* @since 1.0
* @param str
* 需要拆分的字符串("@12@34@56")
* @param token
* 分隔字符串("@")
* @return 以token为分隔的拆分开的字符串数组
*/
public static String[] split(String str, String token) {
String temp = str.substring(1, str.length());
return temp.split(token);
}
/**
* 验证字符串合法性
*
* @since 1.0
* @param str
* 需要验证的字符串
* @param test
* 非法字符串(如:"~!#$%^&*()',;:?")
* @return true:非法;false:合法
*/
public static boolean check(String str, String test) {
if (str == null || str.equals(""))
return true;
boolean flag = false;
for (int i = 0; i < test.length(); i++) {
if (str.indexOf(test.charAt(i)) != -1) {
flag = true;
break;
}
}
return flag;
}
/**
* 将数值型字符串转换成Integer型
*
* @since 1.0
* @param str
* 需要转换的字符型字符串
* @param ret
* 转换失败时返回的值
* @return 成功则返回转换后的Integer型值;失败则返回ret
*/
public static Integer String2Integer(String str, Integer ret) {
try {
return Integer.parseInt(str);
} catch (NumberFormatException e) {
return ret;
}
}
/**
* 将数值型转换成字符串
*
* @since 1.0
* @param it
* 需要转换的Integer型值
* @param ret
* 转换失败的返回值
* @return 成功则返回转换后的字符串;失败则返回ret
*/
public static String Integer2String(Integer it, String ret) {
try {
return Integer.toString(it);
} catch (NumberFormatException e) {
return ret;
}
}
/**
* 比较两字符串大小(ASCII码顺序)
*
* @since 1.1
* @param str1
* 参与比较的字符串1
* @param str2
* 参与比较的字符串2
* @return str1>str2:1;str1<str2:-1;str1=str2:0
*/
public static int compare(String str1, String str2) {//
if (str1.equals(str2)) {
return 0;
}
int str1Length = str1.length();
int str2Length = str2.length();
int length = 0;
if (str1Length > str2Length) {
length = str2Length;
} else {
length = str1Length;
}
for (int i = 0; i < length; i++) {
if (str1.charAt(i) > str2.charAt(i)) {
return 1;
}
}
return -1;
}
/**
* 将阿拉伯数字的钱数转换成中文方式
*
* @since 1.1
* @param num
* 需要转换的钱的阿拉伯数字形式
* @return 转换后的中文形式
*/
public static String num2Chinese(double num) {
String result = "";
String str = Double.toString(num);
if (str.contains(".")) {
String begin = str.substring(0, str.indexOf("."));
String end = str.substring(str.indexOf(".") + 1, str.length());
byte[] b = begin.getBytes();
int j = b.length;
for (int i = 0, k = j; i < j; i++, k--) {
result += getConvert(begin.charAt(i));
if (!"零".equals(result.charAt(result.length() - 1) + "")) {
result += getWei(k);
}
System.out.println(result);
}
for (int i = 0; i < result.length(); i++) {
result = result.replaceAll("零零", "零");
}
if ("零".equals(result.charAt(result.length() - 1) + "")) {
result = result.substring(0, result.length() - 1);
}
result += "元";
byte[] bb = end.getBytes();
int jj = bb.length;
for (int i = 0, k = jj; i < jj; i++, k--) {
result += getConvert(end.charAt(i));
if (bb.length == 1) {
result += "角";
} else if (bb.length == 2) {
result += getFloat(k);
}
}
} else {
byte[] b = str.getBytes();
int j = b.length;
for (int i = 0, k = j; i < j; i++, k--) {
result += getConvert(str.charAt(i));
result += getWei(k);
}
}
return result;
}
private static String getConvert(char num) {
if (num == '0') {
return "零";
} else if (num == '1') {
return "一";
} else if (num == '2') {
return "二";
} else if (num == '3') {
return "三";
} else if (num == '4') {
return "四";
} else if (num == '5') {
return "五";
} else if (num == '6') {
return "六";
} else if (num == '7') {
return "七";
} else if (num == '8') {
return "八";
} else if (num == '9') {
return "九";
} else {
return "";
}
}
private static String getFloat(int num) {
if (num == 2) {
return "角";
} else if (num == 1) {
return "分";
} else {
return "";
}
}
private static String getWei(int num) {
if (num == 1) {
return "";
} else if (num == 2) {
return "十";
} else if (num == 3) {
return "百";
} else if (num == 4) {
return "千";
} else if (num == 5) {
return "万";
} else if (num == 6) {
return "十";
} else if (num == 7) {
return "百";
} else if (num == 8) {
return "千";
} else if (num == 9) {
return "亿";
} else if (num == 10) {
return "十";
} else if (num == 11) {
return "百";
} else if (num == 12) {
return "千";
} else if (num == 13) {
return "兆";
} else {
return "";
}
}
/**
* 将字符串的首字母改为大写
*
* @since 1.2
* @param str
* 需要改写的字符串
* @return 改写后的字符串
*/
public static String firstToUpper(String str){
return str.substring(0,1).toUpperCase()+str.substring(1);
}
}