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

Quick Search    Search Deep

Source code: jmmv/Global.java


1   /*
2    * DiskCat - Disk Cataloguer
3    * Copyright (C) 2002 Julio Merino <slink@unixbsd.org>
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License as
7    * published by the Free Software Foundation; either version 2 of the
8    * License, or (at your option) any later version.
9   
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * General Public License for more details.
14  
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18   * USA
19   */
20  
21  package jmmv;
22  
23  import java.io.File;
24  import java.io.FileInputStream;
25  import java.util.Locale;
26  import java.util.Properties;
27  import java.util.ResourceBundle;
28  
29  /**
30   * Holds Global configuration of a program.
31   *
32   * @author Julio Merino
33   */
34  public class Global {
35      private static ResourceBundle rc;
36      private static Properties props;
37      private static Locale locale;
38  
39      private Global() {}
40      
41      public static void init(String appname) {
42    /* Read the configuration file */
43    File propsFile = new File(appname + ".properties");
44    props = new Properties();
45    try {
46        FileInputStream fis = new FileInputStream(propsFile);
47        props.load(fis);
48        fis.close();
49    } catch (Exception e) {
50        System.out.println("Error reading properties");
51    }
52  
53    locale = new Locale(props.getProperty("LANGUAGE"), props.getProperty("COUNTRY"));
54    Locale.setDefault(locale);
55    
56    rc = ResourceBundle.getBundle("stringsBundle");
57      }
58  
59      public static ResourceBundle getResources() { return rc; }
60      public static Properties getProperties() { return props; }
61      public static Locale getLocale() { return locale; }
62  }