KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nl > justobjects > pushlet > util > Sys


1 // Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
2
// Distributable under LGPL license. See terms of license at gnu.org.
3

4 package nl.justobjects.pushlet.util;
5
6
7 import java.io.IOException JavaDoc;
8 import java.util.Properties JavaDoc;
9 import java.util.Timer JavaDoc;
10
11 /**
12  * Utilities that interact with the underlying OS/JVM.
13  *
14  * @author Just van den Broecke
15  * @version $Id: Sys.java,v 1.2 2005/02/21 16:59:18 justb Exp $
16  */

17 public class Sys {
18
19
20     /** Load properties file from classpath. */
21     static public Properties JavaDoc loadPropertiesResource(String JavaDoc aResourcePath) throws IOException JavaDoc {
22         try {
23             // Use the class loader that loaded our class.
24
// This is required where for reasons like security
25
// multiple class loaders exist, e.g. BEA WebLogic.
26
// Thanks to Lutz Lennemann 29-aug-2000.
27
ClassLoader JavaDoc classLoader = Sys.class.getClassLoader();
28
29             Properties JavaDoc properties = new Properties JavaDoc();
30
31             // Try loading it.
32
properties.load(classLoader.getResourceAsStream(aResourcePath));
33             return properties;
34         } catch (Throwable JavaDoc t) {
35             throw new IOException JavaDoc("failed loading Properties resource from " + aResourcePath);
36         }
37     }
38
39     /** Shorthand for current time. */
40     static public long now() {
41         return System.currentTimeMillis();
42     }
43
44 }
45
Popular Tags