Flat 10% & upto 40% off + 10% Cashback + Free additional Courses. Hurry up

Java File I/O


Java input and output process the input and produces the output based on the input. Java uses stream to perform input and output operation. Package contains the classes which are needed to input and output operation. Stream is a sequence of data. In java there are three streams are created for us automatically which are as follows:

1. It stands for standard input stream. It gives the data to user’s program and usually a keyboard is used as standard input stream.

2. System.out: It stands for standard output stream. It is used to output the data produced by the user’s program and usually a monitor is used to standard output stream.

3. System.err: It stands for standard error stream. It is used to output the error data produced by the user’s program.


There are two types of streams:

1. Input Stream – It reads data from the source.

input stream

2. Output Stream – It writes data to the destination.

output stream

FileInputStream and FileOutputStream :

These classes are used to perform the read data from the files and write data in the file.


FileOutputStream class: This class is used to write the data into the file.


public class Intellipaat{

public static void main(String args[]){


FileOutputstream fo=new FileOutputStream("hello.txt");

String i="Hello Intellipaat ";

byte b[]=i.getBytes();/ /converting string into byte array




catch(Exception e){system.out.println(e);




It will print Hello Intellipaat in file hello.txt.


FileInputStream class: This class is used to read the data from the file.



class ReadHello{

public static void main(String args[]){


FileInputStream fin=new FileInputStream("hello.txt");

int i=0;





}catch(Exception e){system.out.println(e);}




Hello Intellipaat

Learn more about Cross-Platform Mobile Technology for Android and iOS using Java in this insightful blog now!

"0 Responses on Java File I/O"

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

Sales Offer

  • To avail this offer, enroll before 25th April 2018.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer

Sign Up or Login to view the Free Java File I/O.