// Example 143 from page 117 of Java Precisely second edition (The MIT Press 2005) // Author: Peter Sestoft (sestoft@itu.dk) import java.io.*; class Example143 { public static void main(String[] args) throws IOException { fahrenheitCelsiusHtml(); fahrenheitCelsiusText(); } public static void fahrenheitCelsiusHtml() throws IOException { System.out.println("Printing temperature table to file temperature.html"); PrintWriter pw = new PrintWriter(new FileWriter("temperature.html")); pw.println("
Fahrenheit | Celsius |
---|---|
%d | %.1f%n", f, c); } pw.println(" |