Java的Console

新添加的功能

 

<textarea cols="50" rows="15" name="code" class="c-sharp">/** * */ package com; import java.io.Console; enum Color {Red, Black}; /** * @author Administrator * */ public class NewConsole { public static void main(String[] args) { Console c = System.console(); // #1: get a Console char[] pw; pw = c.readPassword("%s", "pw: "); // #2: return a char[] for(char ch: pw) c.format("%c ", ch); // #3: format output c.format("/n"); MyUtility mu = new MyUtility(); while(true) { String name = c.readLine("%s", "input?: "); // #4: return a String c.format("output: %s /n", mu.doStuff(name)); } } } class MyUtility { // #5: class to test String doStuff(String arg1) { // stub code return "result is " + arg1; } } </textarea>

 

 

C:/Documents and Settings/Administrator/workspace/Test2/src>java com.NewConsole
pw:
t e s t
input?: tttt
output: result is tttt
input?: agdfd
output: result is agdfd
input?:

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(java,c,String,Class,output)