how to read a text file using java programing language

Published: 16 August 2022
on channel: Learner's Nation
19
0

This program uses fileinputstream class to take input from a text file using read method.
read method returns -1 when eof end of file is reached. read function reads text as bytes so we have to convert it into char type .
Any read write operation to a file needs to be handled using IOExeption in java. This is checked exception.
and input and output stream shoul be close once read or write is successfully performed to file.