java重定向标准输入输出
2016-10-20 11:00
302 查看
重定向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 + "个账户");
}
}
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 + "个账户");
}
}
相关文章推荐
- 实时得到程序的标准输出,重定向输入输出。。。
- C/C++ 标准输入输出重定向
- c语言标准输入输出重定向到不同文件
- JavaIO之标准输入输出(三)
- linux标准输入输出重定向
- linux 标准输入输出重定向
- Java I/O学习 标准的I/O重定向
- C++标准输入输出重定向
- Java重定向标准输入/输出
- JavaIO之标准输入输出(一)
- 标准输入输出重定向
- 标准输入输出、错误输出、重定向标准输出
- 学习JAVA的标准数据流和输入输出流
- 标准输入输出、错误输出、重定向标准输出
- Java输入输出重定向!
- [java调用外部可执行程序] 2. java输入输出重定向
- Java标准输出重定向到GUI
- java中的IO整理(3)----数据操作流---合并流--压缩流--输入输出重定向 - 老秋的日志 - 网易博客
- java标准的输入输出的含义
- 管道重定向之重定向标准输入输出句柄