read Properties from Path - Android java.util

Android examples for java.util:Properties

Description

read Properties from Path

Demo Code


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

import java.io.InputStream;

import java.util.Enumeration;
import java.util.Properties;

public class Main {
    public static void readProperties(String filePath) {
        Properties props = new Properties();
        try {//from ww  w . ja  v  a  2s  .c  om
            InputStream in = new BufferedInputStream(new FileInputStream(
                    filePath));
            props.load(in);
            Enumeration<?> en = props.propertyNames();
            while (en.hasMoreElements()) {
                String key = (String) en.nextElement();
                String Property = props.getProperty(key);
                System.out.println(key + Property);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials