Here you can find the source of getReader(String filename)
public static BufferedReader getReader(String filename)
//package com.java2s; /* /*from w ww . jav a 2s. co m*/ Created on Mar 4, 2005 The Bungee View applet lets you search, browse, and data-mine an image collection. Copyright (C) 2006 Mark Derthick This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See gpl.html. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. You may also contact the author at mad@cs.cmu.edu, or at Mark Derthick Carnegie-Mellon University Human-Computer Interaction Institute Pittsburgh, PA 15213 */ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.util.zip.GZIPInputStream; public class Main { public static BufferedReader getReader(String filename) { return getReader(new File(filename)); } public static BufferedReader getReader(File file) { BufferedReader in = null; try { InputStream inputStream = new FileInputStream(file); if (file.getName().endsWith(".gz")) inputStream = new GZIPInputStream(inputStream); in = new BufferedReader(new InputStreamReader(inputStream)); } catch (FileNotFoundException e) { System.err.println("Can't find file " + file); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return in; } public static String printStackTrace() { (new RuntimeException("Relax. There's no error, we're just printing the stack trace")).printStackTrace(); return null; } public static String printStackTrace(Throwable e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return sw.toString(); } }