Java Print Stacktrace untuk mengajukan

//printStackTrace() can accept PrintWriter or PrintStream as argument
catch (Exception e) {

    PrintWriter pw = new PrintWriter(new File("file.txt"));
    e.printStackTrace(pw);
    pw.close();
}

/*Credits: 
Stackoverflow Users: 
Less (https://stackoverflow.com/users/587318/less)
Qnan (https://stackoverflow.com/users/190670/qnan)*/
Brave Boar