Java File to Reader newReader(File pathname)

Here you can find the source of newReader(File pathname)

Description

new Reader

License

Open Source License

Declaration

public static BufferedReader newReader(File pathname) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static BufferedReader newReader(File pathname) {

        InputStream is = null;/* w  w  w .  ja  v  a2 s  . c  o  m*/
        try {

            is = new FileInputStream(pathname);
            return new BufferedReader(new InputStreamReader(is, "UTF-8"));

        } catch (IOException e) {
            close(is);
        }

        return null;

    }

    public static void close(Closeable... closeables) {

        for (Closeable c : closeables)
            try {
                c.close();
            } catch (IOException e) {
                /* ignore */ }

    }
}

Related

  1. newReader(File file)
  2. newReader(File file, String charset)
  3. newReader(File file, String encoding)
  4. newReader(String value)
  5. openReader(File file)
  6. openReader(final String file, String charset)
  7. openReader(String dir, String filename, String encoding)