Methods Summary |
---|
public native java.lang.String[] | getAllEnv()
|
public native java.lang.String[] | getEnv(java.lang.String prefix)
|
public native char | getKeyboardInput()
|
public native java.lang.String | getPassword()
|
public java.lang.String | getPassword(java.lang.String prompt)This function prompts the user for the password without echoing
the characters to the terminal.
InputsAndOutputs.getInstance().getUserOutput().print( prompt );
return getPassword();
|
private static java.lang.String | getText()
String s = null;
try
{
BufferedReader in;
in = new BufferedReader(new InputStreamReader(System.in));
s = in.readLine();
}
catch (IOException exc)
{
System.err.println("Caught exception: " + exc);
}
return (s);
|
public static void | main(java.lang.String[] args)
System.loadLibrary("cliutil");
final String sEnvPrefix = "PS_ADMIN_";
boolean bContinue = true;
while (bContinue) {
System.out.println("Menu");
System.out.println("[1] get environment");
System.out.println("[2] get password");
System.out.println("[3] get keyboard press");
System.out.println("[4] get all environment");
System.out.println("[5] exit");
String line = getText();
if (line.equals("1")) {
String [] sEnvVal = new CliUtil().getEnv(sEnvPrefix);
for (int ii=0; ii<sEnvVal.length; ii++) {
//check for prefix AS_ADMIN
String sName = sEnvVal[ii];
if (sName.regionMatches(true, 0, sEnvPrefix, 0,
sEnvPrefix.length())) {
System.out.println(sName);
}
}
}
else if (line.equals("2")) {
String sPassword = new CliUtil().getPassword("Enter password>");
System.out.println("Password entered = " + sPassword);
}
else if (line.equals("3")) {
char c = new CliUtil().getKeyboardInput();
System.out.println("\n key entered = " + c);
}
else if (line.equals("4")) {
String[] envs = new CliUtil().getAllEnv();
System.out.println("Get All Environment");
for (String env : envs) {
System.out.println(env);
}
}
else if (line.equals("5")) {
bContinue =false;
}
else {
System.out.println("You did not entered the right option.");
}
}
|