IO BufferedReader+FileReader

Posted kakaisgood

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IO BufferedReader+FileReader相关的知识,希望对你有一定的参考价值。

    private static final String FILENAME = "c:\\temp\\in.txt";
    public static void main(String[] args) {

        BufferedReader br = null;
        FileReader fr = null;

        try {

            fr = new FileReader(FILENAME);
            br = new BufferedReader(fr);

            String sCurrentLine;

//            br = new BufferedReader(new FileReader(FILENAME));

            while ((sCurrentLine = br.readLine()) != null) {
                System.out.println(sCurrentLine);
            }

        } catch (IOException e) {

            e.printStackTrace();

        } finally {

            try {

                if (br != null)
                    br.close();

                if (fr != null)
                    fr.close();

            } catch (IOException ex) {

                ex.printStackTrace();

            }

        }

    }

 

以上是关于IO BufferedReader+FileReader的主要内容,如果未能解决你的问题,请参考以下文章

Java_io_PrintWriter和BufferedReader

IO流——BufferedReader和BufferedWriter

键盘输入数据的标准格式-BufferedReader

java IO,bufferedReader类

IO流之BufferedReader/BufferedWriter

Java IO流 之 BufferedReader