Here you can find the source of getReader(File file)
Parameter | Description |
---|---|
file | -- the input file |
Parameter | Description |
---|---|
IOException | an exception |
public static BufferedReader getReader(File file) throws IOException
//package com.java2s; //License from project: LGPL 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 { /**//from w ww . j ava 2 s. co m * Returns a buffered reader for a file. * Similar to the getPrintWriter() method gzip compression is supported. * @param file -- the input file * @return BufferedReader for file * @throws IOException */ public static BufferedReader getReader(File file) throws IOException { if (file.getName().endsWith(".gz")) { return new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)))); } return new BufferedReader(new FileReader(file)); } }