Example & Tutorial understanding programming in easy ways.

What is FileInputStream and FileOutputStream in java explain?.

FileOutputStream class:

A FileOutputStream is an output stream for writing data to a file.

If you have to write primitive values then use FileOutputStream.Instead, for character-oriented data, prefer FileWriter.But you can write byte-oriented as well as character-oriented data.

Example of FileOutputStream class:

Simple program of writing data into the file :

import java.io.*;

class javaTest{

public static void main(String args[]){


FileOutputstream fs=new FileOutputStream("myjava.txt");

String s="i like file handlig in java";

byte b[]=s.getBytes();




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

} }

FileInputStream class:

A FileInputStream obtains input bytes from a file.It is used for reading streams of raw bytes such as image data. For reading streams of characters, consider using FileReader.

It should be used to read byte-oriented data.For example, to read image etc.

Example of FileInputStream class:

Simple program of reading data from the file :

import java.io.*;

class Readtest{

public static void main(String args[]){


FileInputStream fis=new FileInputStream("myjava.txt");

int i;




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

} }


Read More →
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!