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();
       }
}
我想在控制端输入一行字符串,敲回车后显示在控制端上,怎么不成功啊?高手解释下!

解决方案 »

  1.   

    System.out.println(“ssss”);
    打个能出的看哪问题
      

  2.   


    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结束
      

  3.   

    我不要util。就用DataInputStream 帮我看看问题出在哪里?
      

  4.   

     因为readutf是阻塞式的方法,所以他一直在等待客户端的输入。所以没有结束
    。方法改为readLine(),程序就通过了..个人见解.