import java.util.*;
import java.util.stream.*;
import java.lang.*;
import java.io.*;
import java.text.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
try {
f();
} catch (Exception ex) {
System.out.println("toString(): " + ex);
System.out.println("getClass(): " + ex.getClass().getName());
System.out.println("getPackage(): " + ex.getClass().getPackage().getName());
System.out.println("getMessage(): " + ex.getMessage());
System.out.println("getStackTrace(): " +
Arrays.stream(ex.getStackTrace())
.map(StackTraceElement::toString)
.collect(Collectors.joining(",")));
System.out.println("getStackTrace(): " +
String.join(
",",
Arrays.stream(ex.getStackTrace())
.map(StackTraceElement::toString)
.toArray(String[]::new)
)
);
System.out.println("getCause(): " + ex.getCause());
}
}
private static void f() throws Exception {
g();
}
private static void g() throws Exception {
h();
}
private static void h() throws Exception {
throw new IOException("file is missing", new ParseException("parsing failed", 42));
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: