IO流的分类和使用四

InputStreamReader的使用

public class Inoutstremreder {
    public static void main(String[] args) {
        try {
            BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(new File("D:\\a.txt")), "UTF-8"));
            String string;
            while(null!=(string=reader.readLine())) {
                System.out.println(string);
            };
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_35681797/article/details/82149897