Android Properties Read readPropertyFile(String filePath)

Here you can find the source of readPropertyFile(String filePath)

Description

Read properties file.

Parameter

Parameter Description
filePath a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static Properties readPropertyFile(String filePath)
        throws IOException 

Method Source Code

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);
    }
}

Related

  1. getProperties(String propsFile)
  2. getProperties(String propsFile, boolean addToSystemProps)
  3. getProperties(String propsFile, boolean addToSystemProps)
  4. loadPropertiyFile(String file)
  5. propertiesToString(Properties p)
  6. toProperties(String fileName)
  7. findBuildPropValueOf(String prop)
  8. findBuildPropValueOf(String prop)