Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
String methodData = "";
try {
throw new Exception();
} catch (Exception e) {
StackTraceElement[] ste = e.getStackTrace();
methodData = ste[0].getClassName() +"." +ste[0].getMethodName() +"(line:" +ste[0].getLineNumber() +")";
}
System.out.println(methodData);
String stackTrace = "";
try {
throw new Exception();
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter ps = new PrintWriter(baos, true);
e.printStackTrace(ps);
ps.close();
stackTrace = new String(baos.toByteArray());
}
// You may want to refine this :
String methodData = stackTrace.substring(stackTrace.indexOf("at ")+3, stackTrace.indexOf(")"));
System.out.println(methodData);