By the talented team way:
String os = System.getProperty("os.name").toLowerCase(); if (os.indexOf("win") >= 0) { p = r.exec("cmd.exe /c set"); } else { p = r.exec("env"); } BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) { String[] inputs = line.split("="); if ("DOCUMENTUM".equalsIgnoreCase(inputs[0])) { retCode = inputs[1]; } } if (br != null) { br.close(); }
I guess System.getenv was way too complex…
Oh, and they use the same method to read a properties file:
while ((record = dis.readLine()) != null) { recCount++; if ((!record.startsWith("#")) && (!record.trim().equalsIgnoreCase(""))) { String[] inputs = record.split("="); params.put(inputs[0], inputs[1]); } }
o dear lord… dare I ask who the talent team is…. I think I am scared of what the answer will be
LikeLike
yes, this is an ootb class from some Documentum product… Sad part is, if you know what it does, and think as junior with a 3-week java training, it makes sense… 😦
LikeLike
Please send me the details of product and version. I will suggest an improvement.
LikeLike
ASSAP, any version, at least from 7.x onwards…
LikeLike