Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/ydp/jai/PropertyUtil.java


1   /*
2    * The contents of this file are subject to the  JAVA ADVANCED IMAGING
3    * SAMPLE INPUT-OUTPUT CODECS AND WIDGET HANDLING SOURCE CODE  License
4    * Version 1.0 (the "License"); You may not use this file except in
5    * compliance with the License. You may obtain a copy of the License at
6    * http://www.sun.com/software/imaging/JAI/index.html
7    *
8    * Software distributed under the License is distributed on an "AS IS"
9    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10   * the License for the specific language governing rights and limitations
11   * under the License. 
12   *
13   * The Original Code is JAVA ADVANCED IMAGING SAMPLE INPUT-OUTPUT CODECS
14   * AND WIDGET HANDLING SOURCE CODE. 
15   * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
16   * Portions created by: _______________________________________
17   * are Copyright (C): _______________________________________
18   * All Rights Reserved.
19   * Contributor(s): _______________________________________
20   */
21  
22  package org.ydp.jai;
23  
24  import java.io.FileInputStream;
25  import java.io.InputStream;
26  import java.util.PropertyResourceBundle;
27  import java.util.ResourceBundle;
28  
29  public class PropertyUtil {
30  
31      private static ResourceBundle b;
32  
33      /** Get bundle from .properties files in the current dir. */
34      private static ResourceBundle getBundle() {
35          ResourceBundle bundle = null;
36          
37          InputStream in = null;
38  
39    try {
40        in = new FileInputStream("properties");
41        if (in != null) {
42                  bundle = new PropertyResourceBundle(in);
43                  return bundle;
44              }
45          } catch (Exception e) {
46              e.printStackTrace();
47          }
48  
49          return null;
50      }
51  
52      public static String getString(String key) {
53          if (b == null) {
54              b = getBundle();
55          }
56          return b.getString(key);
57     }
58  }