Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

*\^ EOFDEMO java*\] Multi Catch . java* \\ 1| { {import java .` $ 1 For File class and File Not Found Exception import java . util . $ For Scanner...

the text file we are reading is supposed to be filled with integers, one integer per line. If one of the lines contains a corrupted piece of data (not an integer), the MultiCatch program stops, reports anerror and exits. Change the flow of control in the sample code in such a way that a corrupted line (or multiple lines) of text file does not prevent the program tocontinue printing out the rest of the numbers from the file.

  • Attachment 1
  • Attachment 2
  • Attachment 3
*\^ EOFDEMO java*\] Multi Catch . java* \\1| { {import java . 10 . * :`$ 1 For File class and File Not Found Exceptionimport java . util .* : $ For Scanner and Input Mismatch Exception*This program demonstrates how multiple exceptions canbe caught with a single catch clause .public class MultiCatch1011public static void main ( String [ ] ares'!12\13\1n't number :`If To hold a number from the file*14\15\try17\I f Open the file .18\File file = new File " Numbers . txt " ) ;19\Scanner input File = new Scanner l files :20$ 1 Process the contents of the file*while ( input File . hasNext ! !*If Get a number from the file*number = input File . next Int !) :`If Display the number .`System . out . print In /number ! :"If Close the file .input File . close ! ! :catch ! F i L E N o t Found Exception | Inputlli snatch Exception Ex !$ 1 Display an error message .37System . out . print In ! " Error processing the file . " I :383940
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question