从InputStreamReader创建BufferedReader以读取文本文件
import java.io.BufferedReader; import java.io.FileInputStream;/*NowJava.com 提供*/ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; public class InputStreamReaderTest { public static void main(String[] args) throws IOException{ InputStream inputStream = null; Reader reader = null;//from 时代Java公众号 - N o w J a v a . c o m BufferedReader buffer = null; try{ inputStream = new FileInputStream("C:/input.txt"); reader = new InputStreamReader(inputStream); buffer = new BufferedReader(reader); int data; while(true){ data = buffer.read(); if(data== -1){ break; } System.out.println("char --> " + (char)data); }