Here you can find the source of openReader(String file)
Parameter | Description |
---|---|
fileName | the name of the file we want to open for reading |
static protected BufferedReader openReader(String file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w ww . j a v a 2s .c om*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class Main { /** * Create a newBufferedReader * * @param fileName * the name of the file we want to open for reading * * @return a reader to a given file */ static protected BufferedReader openReader(String file) { try { File f = new File(file); if (f.exists() == false) { return null; } return new BufferedReader(new FileReader(file)); } catch (Exception e) { e.printStackTrace(); } return null; } }