windows console命令模式俗称dos模式那么 我曾经看到一种在dos模式下运行的服务器窗口,运行中的时候,提示信息末尾有个提示符按照 [\] ->[|] ->[/] ->[-] 依次变换,进而形成转动的"动画"... 相信各位看到过吧? 试问这种"特效"是怎么实现的呢?第二个问题是,在dos模式下运行的java程序,怎么像CS(反恐精英)服务器那样持续捕捉用户的输入呢?
好比一个服务器在运行,我直接输入 show user (回车) 直接可以看到查询结果...酱紫.请赐教!感激万分.
好比一个服务器在运行,我直接输入 show user (回车) 直接可以看到查询结果...酱紫.请赐教!感激万分.
import java.io.IOException;
import java.io.InputStreamReader;/**
* @author Zhangql
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Dos {
public static void main(String[] args) throws IOException {
Dos enterConsole = new Dos();
enterConsole.printConsoleChar();
} /**
* 从控制对接收一行字符串,然后输出到控制台
* @throws IOException
*/
public void printConsoleLine() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.println("Enter your value:");
str = br.readLine();
System.out.println("your value is :" + str);
} /**
* 从控制台接收一个字符
* 然后打印到控制台上
* @throws IOException
*/
public void printConsoleChar() throws IOException {
System.out.print("Enter a Char:");
char i = (char) System.in.read();
System.out.println("your char is :" + i);
}
}