java重定向标准输入输出

来源:互联网 发布:houdini软件下载 编辑:程序博客网 时间:2024/04/28 07:46

重定向stdin stdout,方便读文件.

public class Test {    public static void main(String[] args) throws IOException {        FileInputStream fis=new FileInputStream("红包雨白名单账户.txt");        System.setIn(fis);        PrintStream ps=new PrintStream(new FileOutputStream("红包雨白名单账户.sql"));        System.setOut(ps);        Scanner sc=new Scanner(System.in);        int count = 0;        while(sc.hasNextLine()) {            String str = sc.nextLine();            if(str == null || str.length() == 0) continue;            count++;            System.out.println("insert into mapi_redbag_rain_white_roll (user_id, is_enabled, create_time) values('" + str + "', 'Y', now());");        }        System.out.println("一共有" + count + "个账户");    }}


0 0
原创粉丝点击