Java examples for java.lang:Exception
find Class Name from Throwable
//package com.java2s; public class Main { /**/*w ww. j a v a2 s. c o m*/ * @param t Throwable * @return String */ public static String findClassName(Throwable t) { StackTraceElement ste = getStackTraceElement(t); return ste != null ? ste.getClassName() : "none"; } /** * @param t Throwable * @return StackTraceElement */ public static StackTraceElement getStackTraceElement(Throwable t) { for (StackTraceElement ste : t.getStackTrace()) { if (!ste.isNativeMethod()) { return ste; } } return null; } }