读取文件代码

public static void main(String[] args)throws IOException
    {
        List<Integer> list=new ArrayList<>();
        DecimalFormat df=new DecimalFormat("######0.00");  
         FileInputStream fip = new FileInputStream("D:\\StudyWay\\Harry Potter and the Sorcerer's Stone.txt");
        InputStreamReader reader = new InputStreamReader(fip, "gbk");
        StringBuffer sb = new StringBuffer();
        while (reader.ready()) {
            sb.append((char) reader.read());
        }
        reader.close();
        fip.close();
        }

读取文件内容

posted @ 2019-11-04 17:15  Mac_13  阅读(201)  评论(0编辑  收藏  举报