Problem with a NullPointerException error
Here is my code (it is only one class out of a program but I thought maybe I could get some help without haveing to post the whole program since it is fairly long.):
import java.util.Formatter;
import java.io.FileNotFoundException;
public class PrintPage
{
public Formatter output;
public void Header()
{
TodaysDate day = new TodaysDate();
System.out.printf("%47s", "Robotics Design Report");
System.out.println();
System.out.printf("%49s", "Erik Lindow, Design Manager");
System.out.println();
System.out.printf("%39s", "Report Date ");
day.DayShort();
System.out.println("\n");
}
public void Header2()
{
System.out.printf("%41s%9s%21s\n", "Airplane", "Wing", "Minimum Air Speed");
System.out.printf("%40s%10s%9s%10s\n", "Weight", "Area", "m/2", "mph");
System.out.printf("" + "%13s%10s", "--", "");
System.out.printf("%10s%10s\n", "", "");
}
public void FileHeader1()
{
TodaysDate day = new TodaysDate();
output.format("%47s", "Robotics Design Report" + "\n");
output.format("%49s", "Erik Lindow, Design Mangaer" + "\n");
output.format("%39s", "Report Date ");
day.DayShort();
output.format("\n\n");
}
public void FileHeader2()
{
output.format("%41s%9s%21s\n", "Airplane", "Wing", "Minimum Air Speed");
output.format("%40s%10s%9s%10s\n", "Weight", "Area", "m/2", "mph");
output.format("" + "%13s%10s", "--", "");
output.format("%10s%10s\n", "", "");
}
}
The problem I am having is that when I run the program I get a NullPointerException error at this line:
output.format("%47s", "Robotics Design Report" + "\n");
I don't know why I am getting the error.Also, I am trying to use Formatter to print out the results of this to a file that can be printed....is this the right syntax to do this?
Thanks
Erik

