get Current Line Number - Java java.lang

Java examples for java.lang:Exception

Description

get Current Line Number

Demo Code


//package com.java2s;

public class Main {
    public static int getCurrentLineNumber() {
        StackTraceElement stack[] = (new Throwable()).getStackTrace();
        return stack[1].getLineNumber();
    }/*  w ww. ja va  2 s  .  c o  m*/
}

Related Tutorials