read Value from Properties - Android java.util

Android examples for java.util:Properties

Description

read Value from Properties

Demo Code


//package com.java2s;
import java.io.BufferedInputStream;
import java.io.FileInputStream;

import java.io.InputStream;

import java.util.Properties;

public class Main {
    public static String readValue(String filePath, String key) {
        Properties props = new Properties();
        try {//from  w ww.j  a  v  a2  s .c  om
            InputStream in = new BufferedInputStream(new FileInputStream(
                    filePath));
            props.load(in);
            String value = props.getProperty(key);
            System.out.println(key + value);
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related Tutorials