Question: Fix the errors and rewrite the following code snippet. The code is written to read a text file containing a single integer value per line
Fix the errors and rewrite the following code snippet. The code is written to read a text file containing a single integer value per line and output that integer. You need to know how to handle Exceptions when reading a file. If you notice this code doesn't handle Exceptions. You are NOT allowed to throw the exception out of this method, you must handle it inside the method itself.
public static void fileReadString fname
File new Filefname;
Scanner inf new ScannerFile;
whileinfnext
int inf.nextLine ;
System.out.printlnx;
f close;
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
