Click here to watch in Youtube :
https://www.youtube.com/watch?v=Uj2X6jaOXxc&list=UUhwKlOVR041tngjerWxVccw
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class InputStreamReaderDemo { public static void main(String[] args) throws IOException { InputStreamReaderDemo inputStreamReaderDemo = new InputStreamReaderDemo(); inputStreamReaderDemo.readData(); } private void readData() throws IOException { InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; try { inputStreamReader = new InputStreamReader(System.in); /* * We are connecting the BufferedReader stream * with the InputStreamReader stream for reading * the line by line data from the keyboard. */ bufferedReader = new BufferedReader(inputStreamReader); String data = ""; while (!data.equals("stop")) { System.out.print("Enter data : "); data = bufferedReader.readLine(); System.out.println("data is : " + data); } } finally { if (inputStreamReader != null) { inputStreamReader.close(); } if (bufferedReader != null) { bufferedReader.close(); } } } }
Enter data : hello data is : hello Enter data : bye data is : bye Enter data : welcome data is : welcome Enter data : stop data is : stop
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_InputStreamReader_Read_while_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_InputStreamReader_Read_while_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ebaa49adbc935437412c3f95a1070f272f5231dd/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/?at=master
See also:
No comments:
Post a Comment