Hi. For programmers familiar with C programming, we could print out the line numbers and file names by certain flags like __LINE__ and __FILE__ in the code itself. Is there any way to do such a thing in Java ? Any help would be appreciated. thanks - Himanshu
Java API does not provide any direct way to do this but you can make use of printStackTrace() method. Write your debug statement such that it throws a Throwable and then catches it. Customize printStackTrace() to print the third line of the stack Trace. This will give you the class file and line number. Hope this helps.
Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform