DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30088

Add method to org.apache.commons.lang.SystemUtils to get Environment Variables

           Summary: Add method to org.apache.commons.lang.SystemUtils to get
                    Environment Variables
           Product: Commons
           Version: 2.0 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Lang
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I think a way in which to get a properties object of all of the system 
environment variables would be very usefull.  I have done it on other projects 
using ANT code.  The following function calls 
org.apache.tools.ant.taskdefs.Execute.getProcEnvironment() to get a list of 
the system environment variables:

--BEGIN CODE---------------------------------
private Properties loadEnvironment() {

Properties props = new Properties();
Vector osEnv = Execute.getProcEnvironment();
for (Enumeration e = osEnv.elements(); e.hasMoreElements();) {
     String entry = (String) e.nextElement();
     int pos = entry.indexOf('=');
     if (pos != -1) {
         props.put(entry.substring(0, pos), entry.substring(pos + 1));
     }
}
return props;

}
--END CODE--------------------------

I know there has been a fight in the java community about access to system 
environment variables from within java code and that java.lang.System.getenv
(String name) has been deprecated, that doesn't mean the need doesn't still 
exist.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to