1. HashMap遍历的两种方式
第一种:
Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
效率高,以后一定要使用此种方式!
第二种:
Map map = new HashMap();
Iterator iter = map.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
Object val = map.get(key);
}
效率低,以后尽量少使用!
2. byte[] 转换为InputStream:
第一种:
Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
效率高,以后一定要使用此种方式!
第二种:
Map map = new HashMap();
Iterator iter = map.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
Object val = map.get(key);
}
效率低,以后尽量少使用!
2. byte[] 转换为InputStream:
InputStream in = new StringBufferInputStream(new String(bytes));
InputStream in = new ByteArrayInputStream(bytes);
InputStream in = new ByteArrayInputStream(bytes);
3. 文件读成流:
File dataFile = new File("data.xml");
System.out.println("filepath:" + dataFile.getAbsolutePath());
InputStream in = new FileInputStream(dataFile);
System.out.println("filepath:" + dataFile.getAbsolutePath());
InputStream in = new FileInputStream(dataFile);
4. 锁的应用
锁定: synchronized (iMsgListener) {
iMsgListener.wait(20000);
}
iMsgListener.wait(20000);
}
解锁:
synchronized (iMsgListener) {
iMsgListener.notify();
}
iMsgListener.notify();
}
id 博主 = [[KILONET.CNBLOGS.COM alloc] initWithValue:@"天堂向右,我依然向左"
网名:@"老舟"
兴趣:@"影音,阅读"
动态:@"系统架构设计,Android通信模块开发"
网址:@"http://kilonet.cnblogs.com"
签名:@"--------------------------------------------------
Stay Hungry , Stay Foolish
求 知 若 渴,处 事 若 愚
--------------------------------------------------"
]; // Never Release