Question: String onionDataName is read from input. Write a try block to: Assign onionFStream with a new FilelnputStream that opens the file named onionDataName for reading.
String onionDataName is read from input. Write a try block to:
Assign onionFStream with a new FilelnputStream that opens the file named onionDataName for reading.
Assign dataScanner with a Scanner created using onionFStream.
Read the next integer from the file into onionValue.
Ex: If the input is onion then the output is:
Value read from oniontxt:
Ex: If the input is fail. txt then the output is:
fail.txt: Open operation failed
tableoniontxtoniontxt
import java.util.Scanner;
import java.ioFileNotFoundException;
import java.ioFileInputStream;
public class ReadInputFile
public static void mainString args
Scanner scnr new Scanner
System.in;
FileInputStream onionFStream;
Scanner dataScanner null;
String onionDataName;
int onionValue ;
boolean errorFound false;
onionDataName ;
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
