當前位置: 首頁>>代碼示例>>Java>>正文


Java ConsoleReader.getOutput方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:scouter-project,項目名稱:bytescope,代碼行數:10,代碼來源:BytescopeConsole.java

示例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());
  }
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:12,代碼來源:WorfInteractive.java

示例3: BigBangShell

import jline.console.ConsoleReader; //導入方法依賴的package包/類
public BigBangShell() {
    try {
        reader = new ConsoleReader();
        oout = new PrintWriter(reader.getOutput());

    } catch (Exception e) {
        e.printStackTrace();

    }
}
 
開發者ID:bigbang,項目名稱:bigbang-client-java,代碼行數:11,代碼來源:BigBangShell.java

示例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;
    }
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:52,代碼來源:PizzaScript.java

示例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();
	}
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:73,代碼來源:JLineExample.java


注:本文中的jline.console.ConsoleReader.getOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。