01——java IO流

java输入模板:

public class GameHelper {
    public String getUserInput(String prompt) {
        String inputLine = null;
        System.out.print(prompt + " ");
        try {
            BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
            inputLine = is.readLine();
            if(inputLine.length() == 0) {
                return null;
            }
        }catch (IOException e) {
            System.out.println("IOException: " + e);
        }
        return inputLine;
    }
}

 

posted @ 2015-10-29 22:08  禅意  阅读(138)  评论(0编辑  收藏  举报