1 23 24 27 28 package com.sun.enterprise.cli.framework; 29 30 import java.io.*; 31 32 36 public class CliUtil 37 { 38 public native String [] getEnv(String prefix); 40 public native String [] getAllEnv(); 42 public native String getPassword(); 43 44 50 public String getPassword(String prompt){ 51 InputsAndOutputs.getInstance().getUserOutput().print( prompt ); 52 return getPassword(); 53 } 54 55 static 56 { 57 System.loadLibrary("cliutil"); 58 } 59 60 public static void main(String [] args) 61 { 62 String sEnvPrefix = "PS_ADMIN_"; 63 System.out.println("Menu"); 64 System.out.println("[1] get environment"); 65 String line = getText(); 66 67 if (line.equals("1")) 68 { 69 String [] sEnvVal = new CliUtil().getEnv(sEnvPrefix); 70 for (int ii=0; ii<sEnvVal.length; ii++) 71 { 72 String sName = sEnvVal[ii]; 74 if (sName.regionMatches(true, 0, sEnvPrefix, 0, 75 sEnvPrefix.length())) 76 { 77 System.out.println(sName); 78 } 79 } 80 } 81 else 82 { 83 System.out.println("You did not entered the right option."); 84 } 85 86 } 87 88 private static String getText() 89 { 90 String s = null; 91 92 try 93 { 94 BufferedReader in; 95 in = new BufferedReader(new InputStreamReader(System.in)); 96 s = in.readLine(); 97 } 98 catch (IOException exc) 99 { 100 System.err.println("Caught exception: " + exc); 101 } 102 103 return (s); 104 } 105 } 106 107 | Popular Tags |