Open NgManSing opened 3 years ago
For expected.txt, you only want to include the parts that the program outputs and exclude what the user is supposed to input.
I believe the NoSuchElementException error can be solved by checking if your scanner object has next line using hasNextLine() method before getting the nextLine() value or in the while loop.
I find out that if I declare the Scanner object outside a static method (i.e. declare the static final Scanner object globally) can solve the problem.
I am trying to use the batch file which is for text-ui testing. I have put some inputs into input.txt and have written the expected output into EXPECTED.TXT.
input.txt
EXPECTED.TXT
However, the program only takes the first line in the input.txt and ignored other lines. The compiler replied "Exception in thread "main" java.util.NoSuchElementException: No line found".
Where have I made mistakes?