基础知识 Java 文件读取 行读 字节读取

        //字节流 行读取 String
        File file = new File("C:\\Users\\Administrator\\Desktop\\test.txt");

        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));

        String tempString = null;
        while( (tempString = bufferedReader.readLine()) != null){
            System.out.print(tempString);
        }

        bufferedReader.close();


        //字节读取   int
        FileInputStream fileInputStream = new FileInputStream(("C:\\Users\\Administrator\\Desktop\\test.txt"));
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");

        int temp;
        while((temp = inputStreamReader.read()) != -1){
            System.out.print((char)temp);
        }
        inputStreamReader.close();

 

 

 


 

 

 

      基础

 

上一篇:给.git(github)仓库瘦身(对照官方最新版本)


下一篇:Linux ALSA声卡驱动之一:ALSA架构简介