This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
when I am using C language for programming, I have a tool available to check how control is moving during execution.
Is there something available in java to see the movement of control during execution ? How can I check the control, if I am not getting desired oputput ?
You can put print statements in every method. But the debuggers are easier. You set a breakpoint by double-clicking the left margin of the code, and after the breakpoint you have three options:
Step into: follow through the method called
Step Over: Continue with the calling method, not inspecting the method called.
Step return: Execute to the end of the current method without seeing the intervening steps
You will have to try it to see it working.
Joined: Apr 23, 2009
This is the code.
Nothing is showing in city1.txt file. When I check debug file, follwoing lines are there
"<terminated>ReadLine1 [Java Application]
<terminated, exit value: 0>C:\Program Files\Java\jre6\bin\javaw.exe (2011-02-15 12:06:50 AM)"
What shall I understand from this ? How can I see, why output is not comingup in city1.txt ? Can I checck it through control flow ?
Did you put a break point? You need to have a breakpoint in order for the execution to stop at the breakpoint and then you can use method suggested by Campbell to proceed further execution.
Dont ever have an empty catch block. You are eating up the exception with out the user even getting to know. You can print/log the stacktrace in the catch block.
Also You can have a look at the examples in the tutorial here.
Joined: Oct 13, 2005
You have a serious error, that you are not closing the Reader. You ought to do that in a finally block, like this
Because you have both reading and writing in the same method, your close() methods might not both be called. It is not usually easy to have reading and writing in the same blocks. Consider a reading block which adds the text to a List<String> and a writing block which copies the text out of that List.
Joined: Oct 13, 2005
I have split the reading and writing into two methods, and added some print instructions, and other testing code, marked with //test comments.By the way: in your original post you had an "end" comment about "main thread". You were not ending the main thread, but reaching the end of the main method.