-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebuggingtest.java
More file actions
40 lines (33 loc) · 1.21 KB
/
Debuggingtest.java
File metadata and controls
40 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Chapter11Throwable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.PrintWriter;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Scanner;
public class Debuggingtest {
public static void main(String[] args){
try {
Scanner sc=new Scanner(new FileInputStream("/readme.txt"));
//������ط���ö�ջ����
//Thread.dumpStack();
} catch (Throwable e) {
//e.printStackTrace();
//����ջ���ٲ����ַ�����
ByteArrayOutputStream out=new ByteArrayOutputStream();
PrintWriter writer=new PrintWriter(out);
e.printStackTrace(writer);
String description=writer.toString();
System.out.println("description::==="+description);
//����thread�ľ�̬������ijЩ�Dz����쳣�Ķ�ջ��Ϣ������ļ���
Thread.setDefaultUncaughtExceptionHandler(
new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
// TODO Auto-generated method stub
//������Ϣ��log��־�ļ���
}
});
}
}
}