zoukankan      html  css  js  c++  java
  • java:I/O 根据用户输入反馈信息

    import java.io.*;
    class userInputIO{
                //Java中成员变量有默认初始化,也就是如果不显式设置初始值的话就会被初始化为其类型的默认值(0、false、null等)。 
            private BufferedReader bufferedReader;
            public userInputIO(){
                //System.in用户的输入做成BufferedReader流
                bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            }
            public String getInputLine(){
                String inputLine = null;
                try {
                    inputLine = bufferedReader.readLine(); //用户输入数据之后,按下回车键,该行代码即可读取到用户的输入
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return inputLine;
            }
            
    
    }
    public class Test {
        public static void main(String[] args) {
            userInputIO userInputIO =new userInputIO();
            while(true){
                String input = userInputIO.getInputLine();
                System.out.println(input);
            }
    
        }
    
    }
  • 相关阅读:
    视图
    Mysql事务
    子查询
    Mysql连表查询
    Mysql增删改查
    Mysql数据类型
    EntityFramwork 查询
    Git
    EntityFramework走马观花之CRUD(下)
    EntityFramework走马观花之CRUD(中)
  • 原文地址:https://www.cnblogs.com/tinyphp/p/3778989.html
Copyright © 2011-2022 走看看