We use FilelnputStream class for reading from the file as it creates an input byte stream for reading from the file. To read the contents from the file ecomputernotes.bat, we first make an object by name say fp of FileOutputStream class and specify the file name ecomputernotes.bat as an argument to the constructor:
fp=new FilelnputStream(ecomputernotes.bat ");
If the file is not found or some error occurs in the disk, then the exception FileNotFoundException is thrown. If the file is found and everything is well, the matter is read from the file and is displayed on the screen after casting it into characters (because data in file is in byte form). When file is over, it is closed by fp.close() method.
public static void main(String args) throws IOException
System.out.println("File Cannot be Found");
System.out.println("Data in File is");