
{filelink=4347}
public class StackTraceException {
public static void main(String[] argv) throws Exception {
try {
int x = 6, y = 0;
System.out.println(x / y);// Tenter une division par zero
} catch (Throwable e) {
StackTraceElement stack[] = e.getStackTrace();
for (int i = 0; i < stack.length; i++) {
String fichier = stack[i].getFileName();
if (fichier == null)
{
System.out.println(fichier+" n'est pas disponible");
}
String nomClasse = stack[i].getClassName();
System.out.println(nomClasse);
String nomMethode = stack[i].getMethodName();
System.out.println(nomMethode);
boolean estNative = stack[i].isNativeMethod();
System.out.println(estNative);
int ligne = stack[i].getLineNumber();
System.out.println(ligne);
}
}
}
}