调用第一次shuru()方法可以,第2次掉用怎么不行 ,为什么?
import java.io.*;
public class Shuru {
public static void main(String []args){
System.out.println(shuru());
System.out.println(shuru());
}
public static String shuru(){
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = null;
try {
 s = br.readLine();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}finally{
try {
isr.close();
br.close();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}

}

return s;
}}

解决方案 »

  1.   

    import java.io.*; 
    public class Shuru { 
    public static void main(String []args){ 
    System.out.println(shuru()); 
    System.out.println(shuru()); 

    public static String shuru(){ 
    InputStreamReader isr = new InputStreamReader(System.in); 
    BufferedReader br = new BufferedReader(isr); 
    String s = null; 
    try { 
    s = br.readLine(); 
    } catch (IOException e) { 
    // TODO 自动生成 catch 块 
    e.printStackTrace(); 
    }finally{ 
    try { 
    isr.close(); 
    br.close(); 
    } catch (IOException e) { 
    // TODO 自动生成 catch 块 
    e.printStackTrace(); 
    } } return s; 
    } }
      

  2.   

    我靠,你把流都关掉了,哪能行
    InputStreamReader isr = new InputStreamReader(System.in); 
    BufferedReader br = new BufferedReader(isr); 
    java中的流用的是装饰模式,InputStreamReader和BufferedReader 只是把System.in添加了相应的功能,其实,他们还是同一个流,你把任意一个关闭,其他的都会关闭。
      

  3.   

    主要是关了System.in了.楼主你真行,这事都能干的出来.