import java.io.*;
/**
 * @author JCC
 *
 * 更改所生成类型注释的模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
public class TestStandardInput { public static void main(String[] args) 
throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)) ;
String c = new String();
String d = new String("over") ;
//if (d.equals("over"))
// System.out.println("==") ;
//else
// System.out.println("!=") ;
/*
while(true ){
c=stdin.readLine() ;
if (!c.toUpperCase().equals("OVER"))
System.out.println(c);
else{
System.out.println("exit the program") ;
System.exit(1) ;
}

}
*/
int e ;
while((e=stdin.read())!=-1){
System.out.println((char)e);
}


}
}

解决方案 »

  1.   

    import java.io.*;
    /**
     * @author JCC
     *
     * 更改所生成类型注释的模板为
     * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
     */
    public class TestStandardInput { public static void main(String[] args) 
    throws IOException{
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)) ;
    String c = new String();
    String d = new String("over") ;
    //if (d.equals("over"))
    // System.out.println("==") ;
    //else
    // System.out.println("!=") ;

    while(true ){
    c=stdin.readLine() ;
    if (!c.toUpperCase().equals("OVER"))
    System.out.println(c);
    else{
    System.out.println("exit the program") ;
    System.exit(1) ;
    }

    }

    /*
    int e ;
    while((e=stdin.read())!=-1){
    System.out.println((char)e);
    }
    */

    }
    }