本文整理匯總了Java中jline.console.ConsoleReader.getOutput方法的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleReader.getOutput方法的具體用法?Java ConsoleReader.getOutput怎麽用?Java ConsoleReader.getOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jline.console.ConsoleReader
的用法示例。
在下文中一共展示了ConsoleReader.getOutput方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BytescopeConsole
import jline.console.ConsoleReader; //導入方法依賴的package包/類
private BytescopeConsole() {
try {
console = new ConsoleReader();
writer = new PrintWriter(console.getOutput());
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
示例2: WorfInteractive
import jline.console.ConsoleReader; //導入方法依賴的package包/類
public WorfInteractive() throws WorfException {
try {
reader = new ConsoleReader();
out = new PrintWriter(reader.getOutput());
out.println("Welcome to warp10 token command line");
out.println("I am Worf, security chief of the USS Enterprise (NCC-1701-D)");
} catch (IOException e) {
throw new WorfException("Unexpected Worf error:" + e.getMessage());
}
}
示例3: BigBangShell
import jline.console.ConsoleReader; //導入方法依賴的package包/類
public BigBangShell() {
try {
reader = new ConsoleReader();
oout = new PrintWriter(reader.getOutput());
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: interactiveMode
import jline.console.ConsoleReader; //導入方法依賴的package包/類
private static boolean interactiveMode(JavaScriptEngine engine) {
try {
ConsoleReader reader = new ConsoleReader();
reader.setPrompt(PromptNewLine);
reader.addCompleter(new JavaScriptCompleter(engine));
reader.setBellEnabled(false);
reader.setHistoryEnabled(true);
int lineNo = 1;
int startLine = lineNo;
String line;
String source = "";
PrintWriter out = new PrintWriter(reader.getOutput());
boolean bContinueReading = false;
while (!bExiting && (line = reader.readLine()) != null ) {
source = source + line + "\n";
lineNo++;
bContinueReading = !engine.stringIsCompilableUnit(source);
if (!bContinueReading) {
try {
Object result = engine.runPartialScript(source, startLine);
if (result != null) {
out.println(engine.valueToString(result));
}
} catch (ScriptException se) {
out.println(se.getMessage());
}
startLine = lineNo;
source = "";
}
String prompt;
if (bContinueReading) {
prompt = PromptContinueLine;
} else {
prompt = PromptNewLine;
}
reader.setPrompt(prompt);
}
return true;
} catch (IOException e) {
System.err.println(e.getMessage());
return false;
}
}
示例5: main
import jline.console.ConsoleReader; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
try {
Character mask = null;
String trigger = null;
boolean color = false;
ConsoleReader reader = new ConsoleReader();
reader.setPrompt("prompt> ");
if ((args == null) || (args.length == 0)) {
usage();
return;
}
List<Completer> completors = new LinkedList<Completer>();
if (args.length > 0) {
if (args[0].equals("none")) {
} else if (args[0].equals("files")) {
completors.add(new FileNameCompleter());
} else if (args[0].equals("simple")) {
completors.add(new StringsCompleter("foo", "bar", "baz"));
} else if (args[0].equals("color")) {
color = true;
reader.setPrompt("\u001B[1mfoo\u001B[[email protected]\u001B[[email protected]\u001B[0m> ");
} else {
usage();
return;
}
}
if (args.length == 3) {
mask = args[2].charAt(0);
trigger = args[1];
}
for (Completer c : completors) {
reader.addCompleter(c);
}
String line;
PrintWriter out = new PrintWriter(reader.getOutput());
while ((line = reader.readLine()) != null) {
if (color) {
out.println("\u001B[33m======>\u001B[0m\"" + line + "\"");
} else {
out.println("======>\"" + line + "\"");
}
out.flush();
// If we input the special word then we will mask
// the next line.
if ((trigger != null) && (line.compareTo(trigger) == 0)) {
line = reader.readLine("password> ", mask);
}
if (line.equalsIgnoreCase("quit")
|| line.equalsIgnoreCase("exit")) {
break;
}
if (line.equalsIgnoreCase("cls")) {
reader.clearScreen();
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}