File Read
public class FileRead {
public static void main(String[] args) throws FileNotFoundException, IOException {
FileInputStream fin=new FileInputStream("D://file1.txt"); /* FileIputStream is used to read from file
specified by the path */
BufferedReader br=new BufferedReader(new InputStreamReader(fin)); //BufferedReader reads from file as string
String content=br.readLine();
System.out.println("Content of the file:");
while(content!=null){ // Reads until the content read from file is empty
System.out.println(content);
content=br.readLine();
}
}
}
Output:
Contents of the file ars:
hai...
hello.....
how are you....?