21.1k views
1 vote
Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt and write to an output file named dataOut.txt.

public static void main (String[] args) throws FileNotFoundException
{
String inputFileName = "dataIn.txt";
String outputFileName = "dataOut.txt";
File inputFile = new File(inputFileName);
Scanner in = ________;
...
}

1 Answer

2 votes

Answer:

new Scanner(inputFile)

Step-by-step explanation:

In Java when inputting a file using Scanner class. A Scanner breaks the input into tokens with the help of delimiting patterns, by default which matches the whitespaces and then the tokens that are received may be converted into values of different types by suing different next methods.

User Carlos  Soriano
by
6.1k points