Introduction In this article has detail to read a text file in java with simple java IO class. Sample text File
if you want to read this file content, first you have to import the java.io.* class for input/output operations. Then create objects from these 4 classes, which are 1.File - To access the Text file which want to read. 2.FileInputStream – To Read the file content. 3.BufferedInputStream – To buffer the read streams 4.DataInputStream – To read the data whatever in buffer. Or else you can import these classes individually as shown below, 
First method would be preferable as it is reducing your Line of codes (LOC). Here it is the whole source code for this,

Explanation: Foremost we need to create File object and give the path of the Text file (which you want to read) as constructor.
Read the file content as stream by using FileInputStream and put it into Buffer as passing the reference of FileInputStream to constructor parameter of BufferedInputStream . And read this buffer content by using DataInputStream.
Output of above source, 
Whatever in Text File it would give as result. Download Source Code
Thank you for reading. Murukan |