Re: How to get the line number in the code?
From: Bryce (Work) (spamtrap_at_berzerker-soft.com)
Date: 10/03/03
- Next message: Precision: "[JOBS] Java Jobs at Precision"
- Previous message: Stian: "Re: How to make a executable file, such as myprogram.exe, for java ?"
- In reply to: hiwa: "Re: How to get the line number in the code?"
- Next in thread: Charles: "Re: How to get the line number in the code?"
- Reply: Charles: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 03 Oct 2003 10:08:25 -0400
On 2 Oct 2003 20:32:13 -0700, HGA03630@nifty.ne.jp (hiwa) wrote:
>> >Is there a way to obtain the line number in my code? For example:
>> >1 public class MyClass {
>> >2 int a = 5;
>> >3 System.out.println("Integer variable a was set on line number: " + x);
>> >4 etc.
>> >Where x is equal to '2'.
>> >
>> >How can I obtain 'x' ?
>
>You can use java.io.LineNumberReader of LineNumberInputStream. Both
>class has getLineNumber() method.
Actually, the original poster wanted to do this at runtime. I suppose
you could do some fiddling by reading the .java file into
LineNumberReader, and locating the code you were executing.
- Next message: Precision: "[JOBS] Java Jobs at Precision"
- Previous message: Stian: "Re: How to make a executable file, such as myprogram.exe, for java ?"
- In reply to: hiwa: "Re: How to get the line number in the code?"
- Next in thread: Charles: "Re: How to get the line number in the code?"
- Reply: Charles: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]