※ 为什么循环不能继续?
while (it.hasNext()){
key = it.next();
try{
cc = (ChatClient)chatClients.get(key);
cc.sendln(str);
}catch(Exception e){
//e.printStackTrace();
try {
cc.close();
} catch (Exception e1) {
e1.printStackTrace();
}
chatClients.remove(key);
continue;
}
}
---------
运行以上代码,当发生异常时,循环就退出了。已经捕获异常,并处理了,为什么循环不能继续?
*异常是这个方法抛出的: cc.sendln(str) -> writer.write(s);writer是用socket输出流构造的OutputStreamWriter对象;writer = new OutputStreamWriter(socket.getOutputStream());