// 
// Sample HelloWorld application 
// 
import java.lang.*;
import java.io.*;
public class Factora{     public static void main (String args[])throws IOException { 
       int c;
       int fff;
       int fac = 1;
       while(true){
           c = System.in.read(); 
           System.out.println(c);
           if(c == '~'){
               return;
           } 
       }       
    }        
}//end这个结果好奇怪啊,我无论输入什么单个字符,它先输出其asccii码,接着连续输出 13  10 两个数字
如:
我输入的是a,结果:a
97
13
10是不是按回车键的关系,能不能把它解决掉,谢谢

解决方案 »

  1.   

    我要循环那怎么办?
    除了以下方法还有什么方法?   if(c==13 || c==10)
           continue;
      

  2.   

    import java.lang.*;
    import java.io.*;
    public class Factora{     public static void main (String args[])throws IOException { 
           String c;
           int fff;
           int fac = 1;
              BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
           while(true){
               c = in.readLine(); 
               System.out.println(c);
               if(c == "~"){
                   return;
               } 
           }       
        }        
    }
      

  3.   

    if(c==13)    continue;
      

  4.   

    import java.lang.*;
    import java.io.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    public class Factora{     public static void main (String args[])throws IOException { 
           /*
      char c='a';
           int fff;
           int fac = 1;
      */
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
           String str = null;
      
      while(true){
      
               try{str = reader.readLine();}
      catch(Exception e){ }
               System.out.println(str);
               if(str.equals("~") ){
                   return;
               } 
     
           }       
        }        
    }