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

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