Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.File;

public class Main {
    public static void main(String[] args) throws Exception {
        File outFile = new File("stdout.txt");
        PrintStream ps = new PrintStream(new FileOutputStream(outFile));

        System.out.println(outFile.getAbsolutePath());

        System.setOut(ps);

        System.out.println("Hello world!");
        System.out.println("Java I/O  is cool!");
    }
}