code: public static final String read(final String key, 
          final String valueName) {
          
          try {
              final Process process = Runtime.getRuntime().exec("reg query " + 
                  "\""+ key + "\" /v " + valueName);
              
              final InputStream is = process.getInputStream();
              final StringWriter sw = new StringWriter();;
  
              final Runnable runner = new Runnable() {
  
                  public void run() {
                      try {
                          int c;
                          while ((c = is.read()) != -1) {
                              sw.write(c);
                          }
                      }
                      catch (final IOException e) { 
                          LOG.error("Error reading reg with key '"+key+
                              "' and val '"+ valueName+"'", e);
                      }
                  }
                  
              };
  
              final Thread t = new Thread(runner, "Registry-Reading-Thread");
              t.setDaemon(true);
              t.start();
              process.waitFor();
              t.join();
              final String output = sw.toString();
              
              // This seems like slight overkill, but we want to handle generic
              // whitespace separators to accommodate OS-specific differences.
              final Scanner scan = new Scanner(output);
              String lastValue = "";
              while (scan.hasNext()) {
                  lastValue = scan.next();
              }
              return lastValue;
          } catch (final IOException e) {
              LOG.error("Error reading reg with key '"+key+"' and val '"+
                  valueName+"'", e);
              return "";
          } catch (final InterruptedException e) {
              LOG.error("Error reading reg with key '"+key+"' and val '"+
                  valueName+"'", e);
              return "";
          }
      }
docs: Reads the value of a registry key.
  
  @param key The registry key to query.
  @param valueName Name of the registry value.
  @return registry value or the empty string if not found.