对Unix\Linux有点了解的人,都知道“流”这个概念是多么重要。
对Unix\Linux Shell有点了解的人,都知道3大流,in,out,error。
package test;
import java.io.*;
/**
* Created by IntelliJ IDEA.
* User: depeng
* Date: 2010-6-23
* To change this template use File | Settings | File Templates.
*/
public class IO2File {
public static void main(String[] args) throws IOException {
File f=new File("out.txt");
f.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(f);
PrintStream printStream = new PrintStream(fileOutputStream);
System.setOut(printStream);
System.out.println("默认输出到控制台的这一句,输出到了文件 out.txt");
}
}
对Unix\Linux Shell有点了解的人,都知道3大流,in,out,error。
package test;
import java.io.*;
/**
* Created by IntelliJ IDEA.
* User: depeng
* Date: 2010-6-23
* To change this template use File | Settings | File Templates.
*/
public class IO2File {
public static void main(String[] args) throws IOException {
File f=new File("out.txt");
f.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(f);
PrintStream printStream = new PrintStream(fileOutputStream);
System.setOut(printStream);
System.out.println("默认输出到控制台的这一句,输出到了文件 out.txt");
}
}