write my assignment 15408

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’!12131n’t number :`If To hold a number from the file*1415try17I f Open the file .18File file = new File " Numbers . txt " ) ;19Scanner 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

 
"Not answered?"
Get the Answer