Here you can find the source of readFile(String fileName)
static Properties readFile(String fileName) throws Exception
//package com.java2s; /*/*from w w w.j av a2 s . c o m*/ * MODIFICATIONS to the original source have been made by * Scott Douglass <scott@swdouglass.com> * * Copyright 2009 Scott Douglass <scott@swdouglass.com> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * The original copyright notice and license terms are below. */ import java.io.File; import java.io.FileInputStream; import java.util.Properties; public class Main { static Properties readFile(String fileName) throws Exception { File f = new File(fileName); if (!f.exists()) { throw new IllegalArgumentException("No such file: " + f.getCanonicalPath()); } FileInputStream in = null; try { Properties prop = new Properties(); in = new FileInputStream(f); prop.load(in); return prop; } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { } } } } }