2013年12月15日星期日

How to print exception information ?

StackTrace how to use a line of code to append to a file ?
------ Solution ---------------------------------------- ----
e.printStackTrace(new PrintStream(new FileOutputStream("error.txt")));

------ Solution ------------------------------ --------------

  
  Sentence can not find the file itself will throw an exception .  
file operation will certainly be the exception, only to catch or throw
try{e.printStackTrace(new PrintStream(new FileOutputStream("error.txt",true)));}catch (FileNotFoundException e1){e1.printStackTrace();}

say this is just line code
------ For reference only -------------------- -------------------
e.printStackTrace(new PrintStream(new FileOutputStream("error.log", true)));

------ For reference only ------------- --------------------------
should do if you want to append
e.printStackTrace(new PrintStream(new FileOutputStream("error.txt",true)));

------ For reference only ----------------------------------- ----


Sentence can not find the file itself will throw an exception .
------ For reference only -------------------------------------- -

    
    Sentence can not find the file itself will throw an exception .          
file operation will certainly be the exception, only to catch or throw   
  
try{e.printStackTrace(new PrintStream(new FileOutputStream("error.txt",true)));}catch (FileNotFoundException e1){e1.printStackTrace();}
  
say this is just    line code  
. Thank you .

没有评论:

发表评论