MCPcopy Create free account
hub / github.com/cbeust/jcommander / JDK6Console

Class JDK6Console

src/main/java/com/beust/jcommander/internal/JDK6Console.java:8–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import java.lang.reflect.Method;
7
8public class JDK6Console implements Console {
9
10 private Object console;
11
12 private PrintWriter writer;
13
14 public JDK6Console(Object console) throws Exception {
15 this.console = console;
16 Method writerMethod = console.getClass().getDeclaredMethod("writer");
17 writer = (PrintWriter) writerMethod.invoke(console);
18 }
19
20 public void print(CharSequence msg) {
21 writer.print(msg);
22 }
23
24 public void println(CharSequence msg) {
25 writer.println(msg);
26 }
27
28 public char[] readPassword(boolean echoInput) {
29 try {
30 writer.flush();
31 Method method;
32 if (echoInput) {
33 method = console.getClass().getDeclaredMethod("readLine");
34 return ((String) method.invoke(console)).toCharArray();
35 } else {
36 method = console.getClass().getDeclaredMethod("readPassword");
37 return (char[]) method.invoke(console);
38 }
39 }
40 catch (Exception e) {
41 throw new ParameterException(e);
42 }
43 }
44
45}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…