Question: String endiveDataFile is read from input. The try block opens a file named endiveDataFile to read an integer into valueRead. In the try - with
String endiveDataFile is read from input. The try block opens a file named endiveDataFile to read an integer into valueRead.
In the trywithresources statement, complete the declaration of variable endiveScanner with a new Scanner object. The Scanner object is constructed with a FilelnputStream that is constructed with string endiveDataFile.
Click here for examples
import java.util.Scanner;
import java.ioFileInputstream;
import java.ioIOException;
public class ReadDataFile
public static void mainString args
Scanner scnr new ScannerSystemin;
String endiveDataFile;
int valueRead;
endiveDataFile scnrnext;
try Scanner endiveScanner Your code goes here
valueRead endiveScanner.nextInt;
System.out.printlnValue read from endiveDataFile : valueRead;
catch IOException e
System.out.printlnendiveDataFile : File not available";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
