Example:
package com.w3schools;
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();
}
}
} |
package com.w3schools;
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:
Download this example.