1:
byte[] bytBuff=new byte[100];//这个字符数组是用来存储输入的字符串
try{
System.in.read(bytBuff);
}catch(IOException e){
System.err.println(e);
}
strSrc=new String(bytBuff);
2:
String strTmp=new String();
try{
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input=new BufferedReader(reader);
System.out.println("******:"); //提示输入
strTmp=input.readLine(); }catch(IOException ioe){
System.err.println(ioe.toString());
}
byte[] bytBuff=new byte[100];//这个字符数组是用来存储输入的字符串
try{
System.in.read(bytBuff);
}catch(IOException e){
System.err.println(e);
}
strSrc=new String(bytBuff);
2:
String strTmp=new String();
try{
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input=new BufferedReader(reader);
System.out.println("******:"); //提示输入
strTmp=input.readLine(); }catch(IOException ioe){
System.err.println(ioe.toString());
}
//.............
io.readLine();
//.............
2。通过输入流来获取。其实还是System.in.read();
3。自己写个类,使用KeyListener 接口。使用 public void keyPressed(KeyEvent event)方法 event.getKeyChar获得你敲的字符。。哈哈,这个比较笨啦
import java.util.*;C:\test.java:7: cannot resolve symbol
symbol : method readln (int)
location: class java.io.InputStream
System.in.read(a);
^
system.in.readline(a);
system.io.read();
等等都报同一个错误
int ch = System.in.read();
读取一行:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();