1.将大于符号(<)转义成 > ,小于转移成 < ,等于转移成 =
StringEscapeUtils.unescapeHtml()
2.复制数组
System.arraycopy(src, srcPos, dest, destPos, length);
3.增加一个元素
Connector results[] = new Connector[connectors.length + 1];
System.arraycopy(connectors, 0, results, 0, connectors.length);
results[connectors.length] = connector;
connectors = results;
4.
如果你要将一个数组转换为list时最好将其转换为一个string,使用Arrays.toString代替上面的方法吧。即使对于基本类型的数组该方法也不会出现任何问题。
如果你打算将一个基本类型的数组转换为所对应的封装类型的list,使用Apache Commons Lang吧,关于这个可能你很早就在项目中使用过了,类似下面这样使用ArrayUtils.toObject:
List<Integer> list = Arrays.asList(ArrayUtils.toObject(new int[] { 1, 2 }));
5.Float.compare() Double.compare() 比较equals
field == null ? o.field == null : field.equals(o.field) // 对于null的判断 effective java
6.静态导入
import static com.deppon.cc.module.callin.PhysicalConstants.*;
7.阻止警告
@SuppressWarnings("unchecked")
List<MoveShiftEntity> list = getSqlSession().selectList(
MoveShiftConstants.MOVE_SHIFT_NAMESPACE+"queryMoveShiftList",moveShiftEntity,rowBounds);
return list;
8.泛型静态工厂方法
public class GenericStaticFactory {
// Generic static factory method
public static <K,V> HashMap<K,V> newHashMap() {
return new HashMap<K,V>();
}
public static void main(String[] args) {
// Parameterized type instance creation with static factory
Map<String, List<String>> anagrams = newHashMap();
}
}
9.读取文件java目录下面的文件
String path = "com/deppon/evs/module/uploaddata/server/META-INF/excel/快递员数据日数据.xls";
try {
fileName = new String("快递员数据日数据".getBytes(), "ISO-8859-1");
ClassLoader classLoader = this.getClass().getClassLoader();
excelStream = classLoader.getResourceAsStream(path);
} catch (UnsupportedEncodingException e) {
return returnError(e.getMessage());
} catch (Exception e){
return returnError(e.getMessage());
}
return returnSuccess();
-Xms128M
-Xmx512M
-XX:PermSize=128M
-XX:MaxPermSize=256M
StringEscapeUtils.unescapeHtml()
2.复制数组
System.arraycopy(src, srcPos, dest, destPos, length);
3.增加一个元素
Connector results[] = new Connector[connectors.length + 1];
System.arraycopy(connectors, 0, results, 0, connectors.length);
results[connectors.length] = connector;
connectors = results;
4.
如果你要将一个数组转换为list时最好将其转换为一个string,使用Arrays.toString代替上面的方法吧。即使对于基本类型的数组该方法也不会出现任何问题。
如果你打算将一个基本类型的数组转换为所对应的封装类型的list,使用Apache Commons Lang吧,关于这个可能你很早就在项目中使用过了,类似下面这样使用ArrayUtils.toObject:
List<Integer> list = Arrays.asList(ArrayUtils.toObject(new int[] { 1, 2 }));
5.Float.compare() Double.compare() 比较equals
field == null ? o.field == null : field.equals(o.field) // 对于null的判断 effective java
6.静态导入
import static com.deppon.cc.module.callin.PhysicalConstants.*;
7.阻止警告
@SuppressWarnings("unchecked")
List<MoveShiftEntity> list = getSqlSession().selectList(
MoveShiftConstants.MOVE_SHIFT_NAMESPACE+"queryMoveShiftList",moveShiftEntity,rowBounds);
return list;
8.泛型静态工厂方法
public class GenericStaticFactory {
// Generic static factory method
public static <K,V> HashMap<K,V> newHashMap() {
return new HashMap<K,V>();
}
public static void main(String[] args) {
// Parameterized type instance creation with static factory
Map<String, List<String>> anagrams = newHashMap();
}
}
9.读取文件java目录下面的文件
String path = "com/deppon/evs/module/uploaddata/server/META-INF/excel/快递员数据日数据.xls";
try {
fileName = new String("快递员数据日数据".getBytes(), "ISO-8859-1");
ClassLoader classLoader = this.getClass().getClassLoader();
excelStream = classLoader.getResourceAsStream(path);
} catch (UnsupportedEncodingException e) {
return returnError(e.getMessage());
} catch (Exception e){
return returnError(e.getMessage());
}
return returnSuccess();
-Xms128M
-Xmx512M
-XX:PermSize=128M
-XX:MaxPermSize=256M