
Write a java program to read a file content into a String using available and read methods of java BufferedReaderInput Stream

import java.io.*;
public class ReadFile{
public static void main(String[] args) throws Exception {
File f = new File("C:/Hello.txt");
if(!f.exists() && f.length() < 0){
System.out.println("The specified file does not exist");
}
else{
FileReader fr = new FileReader(f);
BufferedReader reader = new BufferedReader(fr);
String st = "";
while ((st = reader.readLine()) != null) {
System.out.println(st);
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.