Click here to watch in Youtube :
https://www.youtube.com/watch?v=d9r_76YD_XM&list=UUhwKlOVR041tngjerWxVccw
myfile.txt
ScannerDemo.java
https://www.youtube.com/watch?v=d9r_76YD_XM&list=UUhwKlOVR041tngjerWxVccw
myfile.txt
Welcome to India
Welcome to Japan
Welcome to USA
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.Scanner; /* * Scanner reads file. */ public class ScannerDemo { public static void main(String[] args) throws FileNotFoundException { Scanner scanner = null; try { FileReader fileReader = new FileReader("myfile.txt"); BufferedReader bufferedReader = new BufferedReader(fileReader); scanner = new Scanner(bufferedReader); while (scanner.hasNext()) { String strValue = scanner.nextLine(); System.out.println(strValue); } } finally { if (scanner != null) { /* * Scanner's close method when it is done * with the scanner object. Even though a * scanner is not a stream, you need to * close it to indicate that you're done * with its underlying stream. */ scanner.close(); } } } }
Welcome to India
Welcome to Japan
Welcome to USA
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_Scanner_bufferedReader_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_Scanner_bufferedReader_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/16638d65b46bec1088dab744ba69a31424c4a14f/BasicJava/JavaIODemo_Scanner_bufferedReader_App/?at=master
See also:
No comments:
Post a Comment