public class Input{
public static void main(String args[])throws IOException{
DataInputStream in = new DataInputStream(System.in);
String s = in.readUTF();
System.out.println(s);
in.close();
}
}
我想在控制端输入一行字符串,敲回车后显示在控制端上,怎么不成功啊?高手解释下!
public static void main(String args[])throws IOException{
DataInputStream in = new DataInputStream(System.in);
String s = in.readUTF();
System.out.println(s);
in.close();
}
}
我想在控制端输入一行字符串,敲回车后显示在控制端上,怎么不成功啊?高手解释下!
打个能出的看哪问题
import java.util.Scanner;public class Input {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
System.out.println(scanner.next());
}
}
}Ctrl+Z结束
。方法改为readLine(),程序就通过了..个人见解.