Here you can find the source of readPropertyFile(String filePath)
Parameter | Description |
---|---|
filePath | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static Properties readPropertyFile(String filePath) throws IOException
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Properties; public class Main{ /**// w ww .j a v a 2 s . com * Read properties file. * * @param filePath * @return * @throws IOException */ public static Properties readPropertyFile(String filePath) throws IOException { Properties properties = new Properties(); Reader reader = null; try { reader = FileUtil.readFileReader(filePath); properties.load(reader); return properties; } finally { IOUtil.closeReader(reader); } } public static Reader readFileReader(String filePath) throws IOException { File file = new File(filePath); FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(file); } catch (FileNotFoundException e) { throw e; } return new InputStreamReader(fileInputStream); } }