|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sandev.basics.util.EnvGrabber
Provides a utility to return the value of something set as an environment variable. Why there is no reasonable way of getting this in standard Java is beyond me. After some frustrating attempts, the core of this code was nicked from http://www.rgagnon.com/javadetails/java-0150.html. Our thanks to Real Gagnon for posting it and making it available.
The core access was wrapped in a singleton to avoid unnecessary
repeat calls.
| Field Summary | |
protected static java.util.Properties |
envVars
The single reference copy. |
| Constructor Summary | |
EnvGrabber()
|
|
| Method Summary | |
static void |
dumpProperties(java.util.Properties props)
Go through all the property keys and dump out the corresponding values WITHOUT TRUNCATING. |
static void |
envDump()
This method takes its best shot at dumping out a whole bunch of properties to stdout. |
static java.lang.String |
getEnvVar(java.lang.String envVarName)
Given the name of an environment variable, return its value. |
protected static java.util.Properties |
getEnvVars()
Code adapted from www.rgagnon.com |
static java.lang.String |
safeGetEnvVar(java.lang.String envVarName)
Catches any thrown IOException and simply returns null. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static java.util.Properties envVars
| Constructor Detail |
public EnvGrabber()
| Method Detail |
protected static java.util.Properties getEnvVars()
throws java.io.IOException
java.io.IOException
public static java.lang.String getEnvVar(java.lang.String envVarName)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String safeGetEnvVar(java.lang.String envVarName)
public static void envDump()
list method since that truncates the displayed
values (typically right where you wanted to see it).
public static void dumpProperties(java.util.Properties props)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||