Course Solutions Uncategorized (Solved) : Import Javaio Public Class Testfinally Public Static Void Main String Args Fileinputstream Q37614333 . . . .

(Solved) : Import Javaio Public Class Testfinally Public Static Void Main String Args Fileinputstream Q37614333 . . . .

 

import java.io.*;

public class TestFinally{
public static void main(String[] args){
FileInputStream in1 = null;
FileInputStream in2 = null;

//Open an existing file trycatch.txt
File inputFile1 = new File(“trycatch.txt”);
//Open a non-existent file nosuchfile.abc
File inputFile2 = new File(“nosuchfile.abc”);

       //1. Add the try statementhere

//Get file handlers in Byte Stream format
in1 = new FileInputStream(inputFile1);
in2 = new FileInputStream(inputFile2);

int c1;

//Try to read ‘nosuchfile.abc’ till the end of File
while ((c1 = in2.read()) != -1){
System.out.println(“Read from nosuchfile.abc”);
}

//2. Close the try block here
//3. Add a catch block containing meaningful error messages.

//4. Add the finally block here. See instructions in thehandout.

       //Close the files

in1.close();
System.out.println(“Closing file ‘trycatch.txt’ inside finallyblock.”);
in2.close();
System.out.println(“Closing file ‘nosuchfile.abc’ inside finallyblock.”);

//5. Close the

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post