這裏是我的代碼,我有一個非常簡單而中肯:用什麼來代替PrintWriter?
public void sendMessage(String message)
{
writer.println(message);
writer.flush();
}
我真的不喜歡使用PrintWriter的原因也容易下嚥的IOExceptions,這真的是我的唯一的事情使用它除了發送字節數組。我可以使用什麼,不會消耗IOExceptions,並仍然會給我PrintWriter的功能?
你需要什麼樣的功能?換行?格式化?自動沖洗? – Thilo
我認爲沒有什麼不會吞下IOExceptions。如果嘗試/捕捉,如果你嘗試/捕捉打擾,可以使用封裝嘗試/捕獲的靜態方法 – mulax
@mulax:他不抱怨它*拋出*異常,它*它不拋出異常 - 你必須查詢使用'checkError()'。 –