是System.in.read()吗?
[此贴子已经被作者于2004-07-20 11:30:27编辑过]
程序员的代码就是他的语言,呵呵,给你帖一个代码吧(Java的I/O部分比较繁琐,到现在我也没真正掌握,只能按需查阅API)
/* File: ReadInt.java Author: Kai
*/
import java.io.*; public class ReadInt { public static void main(String [] args)throws IOException { BufferedReader din = new BufferedReader( new InputStreamReader(System.in)); System.out.print("anInt: "); //"parseInt" parses the string argument as a signed //decimal integer int anInt = Integer.parseInt(din.readLine()); System.out.println(anInt);
// read an float number System.out.print("a Float: "); float aFloat = Float.parseFloat(din.readLine()); System.out.println(aFloat);
// read an double number System.out.print("a Double: "); double aDouble = Double.parseDouble(din.readLine()); System.out.println(aDouble); } }