From e177f99ae66bdeae2a394c20c7681e95c43b76a8 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 13 Nov 2003 00:08:11 +0000 Subject: [PATCH] Added another version of loadAndGet(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1291 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/util/PropertiesUtil.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/PropertiesUtil.java b/projects/samskivert/src/java/com/samskivert/util/PropertiesUtil.java index b05016db..7805e376 100644 --- a/projects/samskivert/src/java/com/samskivert/util/PropertiesUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/PropertiesUtil.java @@ -1,5 +1,5 @@ // -// $Id: PropertiesUtil.java,v 1.7 2003/11/13 00:05:08 mdb Exp $ +// $Id: PropertiesUtil.java,v 1.8 2003/11/13 00:08:11 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -136,4 +136,21 @@ public class PropertiesUtil return null; } } + + /** + * Like {@link #loadAndGet(File,String)} but obtains the properties + * data via the classloader. + * + * @return the value of the key in question or null if no such key + * exists or an error occurred loading the properties file. + */ + public String loadAndGet (String loaderPath, String key) + { + try { + Properties props = ConfigUtil.loadProperties(loaderPath); + return props.getProperty(key); + } catch (IOException ioe) { + return null; + } + } }