Differences

This shows you the differences between two versions of the page.

Link to this comparison view

javaproperty [2014/10/26 01:52] (current)
Line 1: Line 1:
 +===== Use Property in Java =====
 +<code 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);​
 +        }
 +    }
 +}
 +</​code>​
 +
 +----
 +
 +  * [[javainfo|Back to Java]]
  
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