/[schmitzm]/trunk/src/skrueger/lang/PropertiesLoaded.java
ViewVC logotype

Annotation of /trunk/src/skrueger/lang/PropertiesLoaded.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 833 - (hide annotations)
Thu May 6 19:50:32 2010 UTC (14 years, 9 months ago) by alfonx
File MIME type: text/plain
File size: 2772 byte(s)
Organized Imports and minor improvements in IOUtil.readURLtoString
1 alfonx 802 package skrueger.lang;
2    
3     import java.io.InputStream;
4     import java.net.URL;
5     import java.util.Properties;
6    
7     import org.apache.log4j.Logger;
8    
9     /**
10     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu initialisieren
11     * und mit den Werten einer Datei zu befüllen. ALle Exceptions werden zu
12     * {@link RuntimeException}s.
13     *
14     * @author Stefan A. Tzeggai
15     *
16     */
17     public class PropertiesLoaded extends Properties {
18     private static Logger log = Logger.getLogger(PropertiesLoaded.class);
19 alfonx 812 // private String charSet = null;
20     //
21     // public PropertiesLoaded(URL loadFrom, String charSet){
22     // this(loadFrom);
23     // this.charSet = charSet;
24     // }
25     //
26     // @Override
27     // public synchronized Object get(Object key) {
28     // Object val = super.get(key);
29     // if (val instanceof String) {
30     // String str = (String) val;
31     // try {
32     // return new String (str.getBytes("ISO-8859-1"),"UTF-8") ;
33     // } catch (UnsupportedEncodingException e) {
34     // e.printStackTrace();
35     // return val;
36     // }
37     // }else return val;
38     // }
39 alfonx 802
40     /**
41     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu
42     * initialisieren und mit den Werten einer Datei zu befüllen. ALle
43     * Exceptions werden zu {@link RuntimeException}s.
44     *
45     * @author Stefan A. Tzeggai
46     *
47     */
48     public PropertiesLoaded(URL loadFrom) {
49     super();
50    
51     load(loadFrom);
52     }
53    
54     /**
55     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu
56     * initialisieren und mit den Werten einer Datei zu befüllen. ALle
57     * Exceptions werden zu {@link RuntimeException}s.
58     *
59     * @author Stefan A. Tzeggai
60     *
61     */
62     public PropertiesLoaded(URL loadFrom, Properties defaults) {
63     super(defaults);
64     load(loadFrom);
65     }
66    
67     /**
68     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu
69     * initialisieren und mit den Werten einer Datei zu befüllen. ALle
70     * Exceptions werden zu {@link RuntimeException}s.
71     *
72     * @author Stefan A. Tzeggai
73     *
74     */
75     public PropertiesLoaded() {
76     super();
77     }
78    
79     /**
80     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu
81     * initialisieren und mit den Werten einer Datei zu befüllen. ALle
82     * Exceptions werden zu {@link RuntimeException}s.
83     *
84     * @author Stefan A. Tzeggai
85     *
86     */
87     public PropertiesLoaded(Properties defaults) {
88     super(defaults);
89     }
90    
91     /**
92     * Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu
93     * initialisieren und mit den Werten einer Datei zu befüllen. ALle
94     * Exceptions werden zu {@link RuntimeException}s.
95     *
96     * @author Stefan A. Tzeggai
97     *
98     */
99     public void load(URL loadFrom) {
100     try {
101    
102     InputStream openStream = null;
103     try {
104     openStream = loadFrom.openStream();
105     load(openStream);
106     } finally {
107     if (openStream != null)
108     openStream.close();
109     }
110    
111     } catch (Exception e) {
112     throw new RuntimeException(e);
113     }
114     }
115    
116     }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26