import java.io.*;
public class TestPrint{
  public static void main(String args[])throws IOException{
     InputStream is=System.in;
     int c=0;
     while((c=is.read())!=-1){
      System.out.print((char)c+" ");
     }
  }
}
//输入12345,结果1不显示,输出2 3 4 5,1显示不出来?
//while((c=is.read())!=-1)改成while((c=is.read())!=13)就是对的。

解决方案 »

  1.   

    同样的代码,在我的机器上输出是1 2 3 4 5 run:
    12345
    1 2 3 4 5 
      

  2.   

    while((c=is.read())!=13)
    13是什么意思
      

  3.   

    JDK版本没有关系?难道是LZ的人品问题?解释不通!!!!
      

  4.   

    我一直在命令窗口下运行的,不行,刚去eclipse上运行了一下,可以的
      

  5.   


    我这里也是这样。我想应该是个 BUG . 如果:           InputStream is=System.in;
               int c=0;
               while((c=is.read())!=-1){
                       System.out.print((char)c);
                       //或 System.out.println((char)c+" ");
               }就没有问题
      

  6.   

    不是,昏,我刚发了一遍没弄明白,我是j2se新手,刚学到javaIO,还有好多问题没弄明白呢,12楼替我解决好多问题了,感谢了,不信你问他。
      

  7.   

    呵呵..怪了,在我机子上测试没问题的
    如果你那真有问题,而且你想达到你要的那种效果
    import java.io.*;
    public class TestPrint{
          public static void main(String args[])throws IOException{
                InputStream is=System.in;
                int c=0;
                while((c=is.read())!=-1){
                        System.out.print((char)c+" ");
                }
          }
    }
    试试这样满足你的要求不
      

  8.   

    刚粘错了
    import java.io.*;
    public class TestPrint{
          public static void main(String args[])throws IOException{
                InputStream is=System.in;
                int c=0;
                while((c=is.read())!=-1){
                        System.out.print((char)c+"\t");
                }
          }
    }
    这段代码哈
      

  9.   


    import java.io.*;
    public class TestPrint
    {
          public static void main(String args[])throws IOException
          {
                InputStream is = System.in;
                int c = 0;
                while((c = is.read())!= 13)
                {
                        System.out.print((char)c+" ");
                }
          }
    }
    命令行下,这样就没有问题了。
      

  10.   

    很奇怪,console下回车加空格会吃掉字符
    InputStream is=System.in;
            int c;
            try {
    while((c=is.read())!=-1){
    System.out.print((char)13 + " ");
    System.out.print((char) c);
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    这样只会输出最后一个字符
    eclipse下正常