2 surffor surffor 于 2013.12.11 11:44 提问

BufferedReader readLine阻塞问题

import java.io.*;
class BufferReadWriterEx{
public static void main(String[] args) throws IOException{
try{
File file_book1 = new File("Book1.txt");
file_book1.createNewFile();
System.out.println("请输入书名: ");
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String name = br.readLine();**在此处阻塞**

        System.out.println("请输入价格: ");
        isr = new InputStreamReader(System.in);
        br = new BufferedReader(isr);
        String price = br.readLine();

        System.out.println("请输入作者: ");
        isr = new InputStreamReader(System.in);
        br = new BufferedReader(isr);
        String author = br.readLine();
        br.close();
        isr.close();
        System.out.println("写入" + file_book1.getName() + "...");
        FileWriter fw = new FileWriter(file_book1);
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(name + "\t" + price + "\t" + author + "\t");
        bw.close();
        fw.close();     
    }catch(IOException e){
        e.printStackTrace();
    }
}

}

为什么会阻塞,具体怎么解决?
ps:刚开始学习java,望大家多多指教,不胜感激。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!