从控制台读取Char
//from n o w j a v a . c o m - 时 代 Java //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { String prompt = "nowjava.com"; System.out.println(inChar(prompt)); } public static char inChar(String prompt) { int aChar = 0; inputFlush(); printPrompt(prompt); try { aChar = System.in.read(); } catch (java.io.IOException e) { System.out.println("Input error"); } inputFlush(); /*来自 时 代 J a v a - nowjava.com*/ return (char) aChar; } public static void inputFlush() { int dummy; int bAvail; try { while ((System.in.available()) != 0) dummy = System.in.read(); } catch (java.io.IOException e) { System.out.println(