作者inthehope (小希)
站內java
標題[問題] IO處理
時間Tue Dec 11 07:52:44 2007
書上的一個例子:
import java.io.*;
public class writeTest
{
public static void main(String[] args) throws IOException
------------------
{
FileWriter output = new FileWriter("hi.txt",true);
output.write("hello");
output.close();
}
}
請問為什麼一定要加 throws IOException 呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.126.46.105
推 superlubu:因為 FileWriter 會 throw IOException 啊 ( ̄□ ̄|||)a 12/11 08:14
推 PsMonkey: ^可能 12/11 11:37
推 H45: ^宣告 12/11 12:21
推 TonyQ: 因為寫程式的人懶得考慮IOException的狀況啊~ 12/11 12:22
→ inthehope:想問的是:為什麼不加throw IOException 就編釋不過呢 12/12 15:51
推 LPH66:前三樓的推文讓我笑了XD 12/12 20:44