Here you can find the source of readFile(String fileName)
static Properties readFile(String fileName) throws Exception
//package com.java2s; // Distributed under an Apache License 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()); }/*from w ww .j a v a 2 s . c om*/ 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) { } } } }