You are here:   HomeJava ProgrammingStreamWrite Data to a File Using Scanner in Java Example
by Dinesh Thakur Category: Stream

FileInputStream is a is present in package and is the child class of InputStream class. It reads data in the form of bytes from a text file.

FileInputStream file = new FileInputStream("Hello.txt") ; Here file is the object of FileInputStream class and points to "Hello.txt" file and if the file is not present then program is terminated by generating fileNotFoundException.

Read data from the file.

Here is the Java Example for Reading Data From File:


class ReadDataFile
           public static void main(String args[])
                 FileInputStream file=new FileInputStream("Hello.txt");
                 System.out.println("Show the File Contents ");
                 int ch;
                 catch(IOException e) {}

Reading Data From File