可以啊,比如下面的代码把你输入的字符再输出到屏幕上。
byte[] buffer = new byte[2500];
try {
int len = System.in.read(buffer);
System.out.println(new String(buffer, 0, len));
}catch(IOException ie) {}
byte[] buffer = new byte[2500];
try {
int len = System.in.read(buffer);
System.out.println(new String(buffer, 0, len));
}catch(IOException ie) {}
public static void main(String[] args) {
System.out.println("----- Please edit text -----");
try {
System.out.print("Enter A: ");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String strA = in.readLine();
int a = Integer.parseInt(strA); System.out.print("Enter B: ");
in = new BufferedReader(new InputStreamReader(System.in)); String strB = in.readLine();
int b = Integer.parseInt(strB); System.out.println(a + b);
}
catch (IOException e) {
System.out.println("I/O Error !");
System.exit(1);
}catch(NumberFormatException e){
System.out.println("Prease enter number!");
}
}
}import java.io.*;public class CaretakerTest {
public static void main(String[] args) {
System.out.println("----- Please edit text -----");
try {
System.out.print("Enter A: ");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String strA = in.readLine();
int a = Integer.parseInt(strA); System.out.print("Enter B: ");
in = new BufferedReader(new InputStreamReader(System.in)); String strB = in.readLine();
int b = Integer.parseInt(strB); System.out.println(a + b);
}
catch (IOException e) {
System.out.println("I/O Error !");
System.exit(1);
}catch(NumberFormatException e){
System.out.println("Prease enter number!");
}
}
}
如try {
char c=(char)System.int.read();
}catch(IOException) { }
ok啦