-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDebuggingLesson.java
More file actions
72 lines (67 loc) · 1.75 KB
/
DebuggingLesson.java
File metadata and controls
72 lines (67 loc) · 1.75 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package debugging;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Random;
import java.util.logging.Logger;
/**
* Created by husiv on 10/10/16.
*/
public class DebuggingLesson {
public static void main(String[] args) throws IOException {
//1
Logger.getGlobal().info("info");
System.out.println("print");
//2
//psvm
//4
Random random = new Random() {
public double nextDouble() {
double dbl = super.nextDouble();
Logger.getGlobal().info(dbl + "");
return dbl;
}
};
//5
try{
} catch (RuntimeException e) {
e.printStackTrace();
}
secondMethod();
//6
thredMethod();
//7
//java MyProgram > errors.txt
//8
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
//save to file
}
});
//9
//-verbose
//10
//-Xlint
new Date().getDate();
//http://www.sonarqube.org/
//11
//java console
//12
//jmap - dump:format=b,file=dump.txt processId
//jhat dumpfile.txt
//13
//-Xprof
}
private static void secondMethod() {
Thread.dumpStack();
}
static void thredMethod() throws IOException {
PrintWriter writer = new PrintWriter(new FileWriter(new File("test.txt")));
new Throwable("mtExeption").printStackTrace(writer);
writer.flush();
writer.close();
}
}