01: package isql;
02:
03: import java.io.*;
04: import java.util.*;
05:
06: /**
07: * The SQLExceptionPrint class provides the functionality for printing
08: * stack traces, required since my unfriendly DOS window cant scroll
09: */
10: public class SQLExceptionPrint {
11:
12: final String sFileName = "Log.out"; //log file name
13: final int iFileLength = 10000; //maximum allowable size of the file
14:
15: FileOutputStream fout;
16: PrintStream myoutput;
17:
18: /**
19: * initialize all the exception,error names and file streams
20: */
21: void init() {
22:
23: //this block will store the stck trace in a file named logFile.out
24: try {
25: File f = new File(sFileName);
26: if (f.exists()) {
27: if (f.length() <= iFileLength)
28: fout = new FileOutputStream(sFileName, true);
29: else
30: fout = new FileOutputStream(sFileName);
31: } else
32: fout = new FileOutputStream(sFileName, true);
33: myoutput = new PrintStream(fout);
34: Date date = new Date();
35: myoutput.println(date.toString());
36: myoutput.println("**********************");
37: } catch (IOException e) {
38: //////System.out.println( e.getMessage( ) );
39: }
40:
41: } // init
42:
43: /**
44: * constructor with one argument of type Throwable
45: * @param th Throwable object
46: */
47: public SQLExceptionPrint(Throwable th) {
48:
49: //initialize
50: init();
51:
52: //print the stack trace on the local file named logfile.out
53: th.printStackTrace(myoutput);
54: try {
55: fout.close();
56: myoutput.close();
57: } catch (IOException e) {
58: //////System.out.println( e.getMessage( ) );
59: }
60:
61: } // constr
62:
63: } //class
|