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 ?
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.
You have a serious error, that you are not closing the Reader. You ought to do that in a finally block, like this
Don't catch Exception; since it says IOException, or FileNotFoundException, catch those Exceptions. You will also have to import them.
Don't use tabs for indenting; use spaces.
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.
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.
He got surgery to replace his foot with a pig. He said it was because of this tiny ad: