Question
import java.util.* ; import java.io.* ; /* * * Simple program to test FileNotFoundException */ public class ExceptionTester1 { public static void main(String[] args) {
import java.util.* ;
import java.io.* ;
/*
*
* Simple program to test FileNotFoundException
*/
public class ExceptionTester1
{
public static void main(String[] args)
{
//-----------Start below here. To do: approximate lines of code = 6
// Use a try{...}catch(){..} block and open a file "input.txt" (use the File class)
// read in one word from the file (use a Scanner) and print the length of the word
// The file "input.txt" does not exist so you should catch FileNotFoundException and print:
// "File not found"
//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
System.out.println("Expected:File not found") ;
}
}
Please have the expected output on screenshot along with making sure your output code is well formatted!
Step by Step Solution
3.37 Rating (156 Votes )
There are 3 Steps involved in it
Step: 1
CHUCK import javaioFile import javaioIOException import javautilScanner public class Chuck public static void mainString args throws IOException Scanner s new Scannernew Filechuckdat int numSets snext...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started