Java FileReader Create getFileReader(File file)

Here you can find the source of getFileReader(File file)

Description

get File Reader

License

Open Source License

Declaration

public synchronized static BufferedReader getFileReader(File file)
            throws IOException 

Method Source Code

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

import java.io.BufferedReader;

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

import java.io.FileReader;

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

import java.util.zip.GZIPInputStream;

public class Main {
    public synchronized static BufferedReader getFileReader(File file)
            throws IOException {
        return file.getName().endsWith(".gz") ? new BufferedReader(
                new InputStreamReader(new GZIPInputStream(
                        new FileInputStream(file)))) : new BufferedReader(
                new FileReader(file));
    }//from   w  ww.  ja v  a2 s. c om

    public synchronized static BufferedReader getFileReader(String fileName)
            throws IOException {
        return getFileReader(new File(fileName));
    }
}

Related

  1. getFileReader(File file)
  2. getFileReader(String filename)
  3. getFileReader(String fileName)
  4. getFileReader(String fileName)
  5. getFileReader(String filePath)