Ask Question

Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops is the correct way to read data from the file until the end of the file is reached?

+5
Answers (1)
  1. 1 April, 20:55
    0
    while (inputFile. hasNext ()) { / /some code here }

    Explanation:

    Even though you did not provide the options, here is how it should look like.

    It is known in the question that there is an object called inputFile. To be able to read all the data from a file in Java, you need to use hasNext () function with the object. inputFile. hasNext () enables you to read the data in a file.

    while (inputFile. hasNext ()) { } enables you to loop through the file while it has something to read in a file.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops is the correct way to ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers