Steps
- Create the FileReader object using file name as an input to FileReader constructor.
- Pass that FileReader object to BufferedReader.
- Read the line from BufferedReader object till readline gets null.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class FileReadTest {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new FileReader("C:\\temp\\test.txt"));
String line = "";
while((line = br.readLine()) != null)
{
System.out.println(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Java Swing Programming Interview Questions and Answers
ReplyDeletehttp://allinterviewquestionsandanswerspdf.blogspot.in/2016/06/top-25-java-swing-programming-interview.html