20package com.sun.star.lib.loader;
22import java.io.BufferedReader;
23import java.io.IOException;
24import java.io.InputStreamReader;
25import java.nio.charset.Charset;
26import java.util.regex.Matcher;
27import java.util.regex.Pattern;
33final class WinRegKey {
35 private final String m_keyName;
40 public WinRegKey( String keyName ) {
44 private static void close(BufferedReader c) {
45 if (c ==
null)
return;
48 }
catch (IOException e) {
56 public String getStringValue() throws WinRegKeyException {
57 BufferedReader r =
null;
59 Process
p =
Runtime.getRuntime().exec(
new String[]{
"reg",
"QUERY", m_keyName});
60 r =
new BufferedReader(
61 new InputStreamReader(
p.getInputStream(), Charset.defaultCharset()));
69 Matcher
m =
pt.matcher(s);
72 throw new WinRegKeyException(
"reg QUERY did not provided expected output");
78 int e =
p.exitValue();
80 throw new WinRegKeyException(
"reg QUERY exited with " + e);
83 throw new WinRegKeyException(
"reg QUERY did not provided expected output");
86 }
catch (WinRegKeyException e) {
88 }
catch (Exception e) {
89 throw new WinRegKeyException(e);