public class HelloWorld{
public static void main (String args[]) {
System.out.println ("input, please:");
String str;
str=System.in.read();
System.out.println (str);
}
}
public static void main (String args[]) {
System.out.println ("input, please:");
String str;
str=System.in.read();
System.out.println (str);
}
}
public static void main(String[] args){
String str="";
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader bfReader=new BufferedReader(in);
boolean notExit=true;
System.out.println("===== I/O testing, print \"exit\" to quit. ======");
//+ "\r\nPlease input:");
try{
while(notExit){
System.out.print("Please input: ");
str=bfReader.readLine();
if (str.equalsIgnoreCase("exit")){
notExit=false;
}else{
System.out.println("System output: " + str);
}
}
}catch(IOException ex){
}
System.out.println("System exit...");
}
}
我还想问的是用System.in下面的方法是否可以实现输入串?
import java.io.*;
....
BufferReader br=new BufferReader(new InputStreamReaer(System.in));
String str=br.readLine();
.....
再问一下,
System.out.println()应该是指java的src下的lang目录下的System.java文件的内容吧!
那.out.println是不是一个方法;
有没有.in.*的方法?
|
|__public static InputStream inin 是System的一个输入流静态变量,InputStream类型,你可以查看java.io.InputStream类所罗列的该类提供的方法.多看看api文档.
我刚刚接触JAVA,在看API文档,不明白就问了。
我本来以为out.println()是system中的方法,in.*也应该是的,可是在system.java文件中找不到,呵呵!不好意思。