Re: How to get the line number in the code?
From: Bryce (Work) (spamtrap_at_berzerker-soft.com)
Date: 10/03/03
- Next message: James: "Re: Help Me!"
- Previous message: Bryce (Work): "Re: sun dies --> java dies ?"
- In reply to: Charles: "Re: How to get the line number in the code?"
- Next in thread: hiwa: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 03 Oct 2003 14:37:39 -0400
On Fri, 3 Oct 2003 11:34:01 -0400, "Charles" <csw@rogers.com> wrote:
>Correct, I wish to be able to do this at runtime. I was hoping for a quick
>and easy way to do this with minimum overhead.
Then the answer is no.
>"Bryce (Work)" <spamtrap@berzerker-soft.com> wrote in message
>news:ik0rnv0eq9orokfhniq29l43qemfirrkta@4ax.com...
>> 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: James: "Re: Help Me!"
- Previous message: Bryce (Work): "Re: sun dies --> java dies ?"
- In reply to: Charles: "Re: How to get the line number in the code?"
- Next in thread: hiwa: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]