File I/O with Primitive Data Type In Java

In java, basic input-output stream provides a method for reading & writing bytes or character in a file. If we want to read-write primitive data typa(such as int , float etc.) than we can use filter classes to filter data in the original stream.

DataInputStream & DataOutputStream are two filter classes used for creating “data streams” for handling primitive data type.

Example: Write a program to write & read a primitive data on a same file.