Do you have an infinite loop or a recursive call?
How many times does your code loop in the while() loop? What causes/lets the loop end?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
You don't need two while loops for populating your Deque; also your logic is flawed at this place:
character = inputFile.readChar();
while (!character.equals('\u0003')) {
if (character.equals('\u0008'))
deck.removeBack();
else
deck.addToBack(character);
}
As soon as you read a character which is not '\u0003', the control enters the second `while` and never moves out since you don't change `character` inside the loop.
Since you have your catch block outside your logic, an EOFException would cause the control to move out of your logic and never execute the part which follows.
Also, I hope you are reading a char which was written using writeChar; if not, use a Scanner for reading simple text files.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Is there a specific code to tell it that the end of file has been reached
Have you read the the API doc for the class and method you are using to read from the file? It should be explained there.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
~s.o.s~ explained how you get into an infinite loop in a while loop.
You need to provide an exit from the loop.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656