Re: [問題] PrintStackTrace

看板java作者 (風月)時間18年前 (2007/07/18 16:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
try the following code: import java.io.File; import java.io.PrintStream; public class exToFile { public static void main(String[] args) { File f = null; PrintStream ps = null; int a = 0; try { f = new File("debug.out"); ps = new PrintStream(f); a = 1/0; } catch(Exception ex){ if (ps != null){ ex.printStackTrace(ps); } } } } Environment: =============================================== JDK : 1.5_02 OS : windows 2k Svr Sp4 IDE : Eclipse 3.2.2 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.67.10.34
文章代碼(AID): #16dSxSBD (java)
文章代碼(AID): #16dSxSBD (java)