重定向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 + "个账户");
}
}