- public class SayInFile {
- public SayInFile(){
- try {
- //文件生成路径
- PrintStream ps=new PrintStream("D:\role.txt");
- System.setOut(ps);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- System.out.println("我在文件里了!");
- }
- }