从主方法引发异常
import java.io.IOException; //N o w J a v a . c o m public class Main { public static void main(String[] args) throws IOException { char c = '\u0000'; System.out.print("Enter some text and then press Enter key: "); c = readChar(); System.out.print("The first character you entered is: " + c); } public static char readChar() throws IOException { char c = '\u0000'; int input = 0; input = System.in.read();