Develop a java console banking system and
Implement the following java concept in your solution and highlight in your documentation or code where you did it:
1. Class and Object
2. File and Stream
3. Exception Handling
SOLUTION TO THE ABOVE QUESTION
package com.company;
import java.io.*;
//Define a class called File_handling_class
public class File_handling_class {
    public static void main(String args[]) throws IOException {
        //Lets us two objects one for input stream and the other for output stream
        FileInputStream input_object = null;
        FileOutputStream output_object = null;
        //Let us handle exception using the try block
        try {
            input_object = new FileInputStream("input.txt");
            output_object = new FileOutputStream("output.txt");
            int condition;
            while ((condition = input_object.read()) != -1) {
                output_object.write(condition);
            }
        }finally {
            if (input_object != null) {
                input_object.close();
            }
            if (output_object != null) {
                output_object.close();
            }
        }
    }
}
Comments