Click here to watch in Youtube :
https://www.youtube.com/watch?v=kdJO4miGfro&list=UUhwKlOVR041tngjerWxVccw
myfile.txt
ScannerDemo.java
https://www.youtube.com/watch?v=kdJO4miGfro&list=UUhwKlOVR041tngjerWxVccw
myfile.txt
Dave went to London
Peter gone to Japan
Juli went to USA
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /* * Scanner reads file. */ public class ScannerDemo { public static void main(String[] args) throws FileNotFoundException { Scanner scanner = null; try { File file = new File("myfile.txt"); scanner = new Scanner(file); while (scanner.hasNext()) { String strValue = scanner.nextLine(); System.out.println(strValue); } } finally { if (scanner != null) { scanner.close(); } } } }
Dave went to London
Peter gone to Japan
Juli went to USA
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_Scanner_file_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_Scanner_file_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/16638d65b46bec1088dab744ba69a31424c4a14f/BasicJava/JavaIODemo_Scanner_file_App/?at=master
See also:
No comments:
Post a Comment