CS 122 Winter 1999, Instructor: Jeffrey Horn
Here is code that will work!
// CLASS EXERCISE on FILE I/O in Java
//
// Task here is simply to print to a file the same way we
// have been printing to the system console (namely, with the
// "println()" method of an object like System.out).import java.io.*;
class GenerateTopics{
public
static void main(String arg[]) throws Exception
{
// Declare what we'll need.
PrintStream mirror;
FileOutputStream mirrorFileStream;
File mirrorFile;
// Create objects we'll need.
mirrorFile = new File("mirror");
mirrorFileStream = new FileOutputStream(mirrorFile);
mirror = new PrintStream(mirrorFileStream);
// Test them.
System.out.println("Look what I can print");
mirror.println("Look what I can write (to a file)." );}
}