import java.io.*;
public class FileReaderDemo
{
public static void main(String args[]) throws FileNotFoundException,IOException
{
File file1=new File("Demo.txt"); // or u can use file name with path eg. D:\\Demo\\Demo.txt
BufferedReader in = new BufferedReader(new FileReader(file1));
String str;
while ((str = in.readLine()) != null) {
System.out.print(str);
}
in.close();
}
}
Save above contents in a file called FileReaderDemo.java
No comments:
Post a Comment