Tutorialspoint examples

Learn java tutorial with examples for beginners online

convert inputstream to bufferedreader java program


Example:

package com.tutorialspointexamples;
 
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
 
public class InputStreamToBufferedReader {
  public static void main(String args[]){
      InputStream is = null;
      BufferedReader bfReader = null;
      try {
          is = new FileInputStream("D:/Test files/file 3.txt");
          bfReader = new BufferedReader(new InputStreamReader(is));
          String temp = null;
          while((temp = bfReader.readLine()) != null){
              System.out.println(temp);
          }
      } catch (Exception e) {
          e.printStackTrace();
      } 
  }
}

Output:

Content file 3

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status