Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- *
- * @author Mirra Ariesta
- */
- public class ReadFile {
- public static void m() throws FileNotFoundException, IOException {
- File file = new File("Data.txt");
- BufferedReader fileReader;
- fileReader = new BufferedReader(new FileReader(file));
- while (true) {
- String line = fileReader.readLine();
- if (line == null) {
- break;
- }
- System.out.println(line);
- }
- }
- public static void main(String args[]) {
- try {
- m();
- } catch (FileNotFoundException ex) {
- System.out.println("File tidak ada");
- } catch (IOException ex) {
- System.out.println("Error IO Exception");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment