Created
October 22, 2014 03:49
-
-
Save erikgunawan/56dce18ba33d2dd4d027 to your computer and use it in GitHub Desktop.
Membaca File *.txt Menggunakan Scanner 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.File; | |
import java.io.FileNotFoundException; | |
import java.util.Scanner; | |
/** | |
* @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 BacaTextFile { | |
public static void main(String[] args) { | |
String lokasi_file = "D:/BacaText/data.txt"; | |
try { | |
File f = new File(lokasi_file); | |
Scanner s = new Scanner(f); | |
while(s.hasNextLine()){ | |
String text = s.nextLine(); | |
System.out.println(text); | |
} | |
} | |
catch (FileNotFoundException fnfe) { | |
fnfe.getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment