Created
October 22, 2014 03:45
-
-
Save erikgunawan/7d89adc022fa2d2be507 to your computer and use it in GitHub Desktop.
Membaca File *.txt Menggunakan BufferedReader dengan Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
/** | |
* @Developer : Erik Gunawan | |
* @Nickname : EXz | |
* @Phone : 0896 5332 0577 | |
* @EMail : admin@erikgunawan.com | |
* @Gmail : erik.gunawan44@gmail.com | |
* @Website : www.erikgunawan.com | |
* @Facebook : facebook.com/revolutionist.exz | |
* @Twitter : twitter.com/_EXz | |
*/ | |
public class BacaFileTxt { | |
public static void main(String[] args) { | |
String lokasi_file = "data.txt"; | |
try { | |
FileReader fr = new FileReader(lokasi_file); | |
BufferedReader br = new BufferedReader(fr); | |
String text; | |
while ((text = br.readLine()) != null) | |
System.out.println(text); | |
} | |
catch (FileNotFoundException fnfe) { | |
fnfe.getMessage(); | |
} | |
catch (IOException ioe) { | |
ioe.getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment