29 lines
901 B
Java
29 lines
901 B
Java
package Course_Codes;
|
||
|
||
import java.io.BufferedReader;
|
||
import java.io.IOException;
|
||
import java.io.InputStreamReader;
|
||
|
||
//基于 BufferedReader 的Java快读快读演示
|
||
public class 快读演示 {
|
||
public static void main(String[] args) {
|
||
//System.in:读取字节流 InputStreamReader字节流->字符流转换的一个桥梁
|
||
//BufferedReader类:从字符输入流中带缓存功能的读取字符,readline()按行读取字符串
|
||
//eg:
|
||
//37 65
|
||
//74 415
|
||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||
String line="";//每次从in里面读取一行字符串
|
||
try {
|
||
while((line=in.readLine())!=null){//只要还有行就继续读取,每次读取一行放到line字符串里
|
||
String[] s=line.split(" +");//+表示会将多个空格看成一个空格
|
||
int a=Integer.parseInt(s[0]);
|
||
int b=Integer.parseInt(s[1]);
|
||
System.out.println(a+b);
|
||
}
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|