Re: How to get the line number in the code?
From: Charles (csw_at_rogers.com)
Date: 10/03/03
- Next message: viator: "Help Me!"
- Previous message: ben arthur: "sun dies --> java dies ?"
- In reply to: Bryce (Work): "Re: How to get the line number in the code?"
- Next in thread: Bryce (Work): "Re: How to get the line number in the code?"
- Reply: Bryce (Work): "Re: How to get the line number in the code?"
- Reply: hiwa: "Re: How to get the line number in the code?"
- Reply: Chris: "Re: How to get the line number in the code?"
- Reply: Raymond DeCampo: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 3 Oct 2003 11:34:01 -0400
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.
"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: viator: "Help Me!"
- Previous message: ben arthur: "sun dies --> java dies ?"
- In reply to: Bryce (Work): "Re: How to get the line number in the code?"
- Next in thread: Bryce (Work): "Re: How to get the line number in the code?"
- Reply: Bryce (Work): "Re: How to get the line number in the code?"
- Reply: hiwa: "Re: How to get the line number in the code?"
- Reply: Chris: "Re: How to get the line number in the code?"
- Reply: Raymond DeCampo: "Re: How to get the line number in the code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]