Use Property in Java

import java.lang.*;
import java.util.*;
import java.io.*;
 
public class Prop
{
    public static final String PROPERTY_FILE = "properties.config";
 
    public static void main(String args[]) {
        try {
            FileInputStream fr = new FileInputStream(new File(PROPERTY_FILE));
            PropertyResourceBundle prb = new PropertyResourceBundle(fr);
            Enumeration properties = prb.getKeys();
            int numProperties = 0;
            while (properties.hasMoreElements()) {
                String key = (String) properties.nextElement();
                System.out.println("e="+ key + " = " + prb.handleGetObject(key));
            }
        }
        catch (FileNotFoundException e) {
            System.err.println(e);
        }
        catch (IOException e) {
            System.err.println(e);
        }
    }
}

javaproperty.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0