1:数组的复制(引用复制)
System.arraycopy(source,index, target, index, len)
重建数组
Integer [] copyOf = Arrays.copyOf(band,band.size());
2:使用预编译sql操作oracle时,性能问题
public void saveInsert(final List<BeanTask> tasks) { if (tasks.size() < 1) return; String sql = "insert into CHANNEL_SWITCH (ID, CHANNEL_ID, CHANNEL_NAME, SWITCH_TIME, K, N, S) values (channelswitch_sequence.Nextval, ?, ?, SYSDATE, ?, ?, ?)";//sysdate会使用oracle每次都重新编译sql,可以得到当前系统时间拼到sql中 jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { public void setValues(PreparedStatement ps, int i) throws SQLException { BeanTask task = tasks.get(i); ps.setString(1, task.getChannelID()); ps.setString(2, task.getChannelName()); ps.setDouble(3, task.getK()); ps.setDouble(4, task.getN()); ps.setDouble(5, task.getS()); } public int getBatchSize() { return tasks.size(); } }); }
3:使用configuration读取配置文件
maven包
<properties>
<configuration.version>1.6</configuration.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>${configuration.version}</version>
</dependency>
</dependencies>
<configuration.version>1.6</configuration.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>${configuration.version}</version>
</dependency>
</dependencies>
读取list
try { PropertiesConfiguration pc = new PropertiesConfiguration("dev.properties"); Iterator keys = pc.getKeys(); while (keys.hasNext()) { String department = keys.next().toString(); List<String> dev = pc.getList(department); devDepartmentCache.put(department, dev); } } catch (ConfigurationException e) { logger.error("read properties file error :dev.properties", e); }
配置文件中的内容(用逗号分隔)
billing=CCN-BJ-J-5KX
log=CCN-BJ-J-5KV,CCN-BJ-J-3g2
log=CCN-BJ-J-5KV,CCN-BJ-J-3g2
4:数据组的初始化,总是记不住备忘下
String数组初始化方式:
(1).String[] temp= new String[] {"aa","bb" };
(2).String[] temp= {"aa","bb" };
(3).String[] temp= new String[2];
temp[0]= "aa";
temp[1]= "bb";
(1).String[] temp= new String[] {"aa","bb" };
(2).String[] temp= {"aa","bb" };
(3).String[] temp= new String[2];
temp[0]= "aa";
temp[1]= "bb";
5:list转换为数组
String[] array = (String[])list.toArray(new String[list.size()])
数组转换为list
List<String> list=Arrays.asList(array);
基本类型数组与包装类型数组转换
Long[] object = ArrayUtils.toObject(new long[1]);
6:数组排序
Arrays.sort() 默认升序