转换流(InputStreamReader)

2/10/2017来源:ASP.NET技巧人气:1520

package inputDemo; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; /** * InputStreamRead是一个读入器,同时也是一个 转换流; * InputStreamRead类将含有字节的流转换为Unicode编码的字符流; * * @author king_wang * */ public class InputStreamReadDemo { public static void main(String[] args) throws IOException{ InputStreamReader in=new InputStreamReader( new FileInputStream("E:\\file.txt")); int c = -1; while((c = in.read()) != -1){ System.out.PRint((char)c); } in.close(); } }