Java BufferedReader Create getBufferedReader(String filename, String encoding)

Here you can find the source of getBufferedReader(String filename, String encoding)

Description

get Buffered Reader

License

Apache License

Declaration

public static BufferedReader getBufferedReader(String filename, String encoding)
            throws FileNotFoundException, IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

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

import java.util.zip.GZIPInputStream;

public class Main {
    public static final String GZIP_FILENAME_EXTENSION = ".gz";

    public static BufferedReader getBufferedReader(String filename, String encoding)
            throws FileNotFoundException, IOException {
        if (filename.endsWith(GZIP_FILENAME_EXTENSION))
            return new BufferedReader(new InputStreamReader(
                    (InputStream) new GZIPInputStream(new FileInputStream(filename)), encoding));
        else/*  w  ww  .  jav a2  s  . c o m*/
            return new BufferedReader(new InputStreamReader((InputStream) new FileInputStream(filename), encoding));
    }
}

Related

  1. getBufferedReader(Reader r)
  2. getBufferedReader(Reader rd)
  3. getBufferedReader(String directory, String filename)
  4. getBufferedReader(String file)
  5. getBufferedReader(String filename)
  6. getBufferedReader(String nombreFichero)
  7. getBufferedReader(String szFile)
  8. getBufferedReaderAsResource(Class clazz, String fileName)
  9. getBufferedReaderFromFileName(File file)