Im hallway through my java course and Im learning how to write programs that save information to files. The code written below actually works fine when I run it only problem is that When i try to open the pages file after writing to it pages cannot open the file. I get a message saying pages can't read the file. it seems that when the print stream writes to a pages file it corrupts it in some way. the error message is coming from the Mac OS so there is nothing wrong with the code (which is being run in eclipse). Ihe exact error message is (Pages couldn’t read the file. You can try restoring to a previous version)
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
class WriteOK {
public static void main(String args[])throws FileNotFoundException {
PrintStream diskWriter = new PrintStream(new File("/Users/jonathanhickey/Desktop/test.pages"));
diskWriter.println("OK");
diskWriter.close();
}
}