fork download
  1. import java.io.FileWriter;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4.  
  5. /**
  6.  * Example 143 - Printing an HTML Table
  7.  */
  8. class PrintHTMLTable {
  9.  
  10. public static void main(String[] args) throws IOException {
  11. PrintWriter pw = new PrintWriter(new FileWriter("temperature.html"));
  12. pw.println("<TABLE BORDER><TR><TH>Fahrenheit<TH>Celsius</TR>");
  13. for (int f = 10; f <= 200 ; f += 10) {
  14. double c = 5 * (f - 32.0) / 9;
  15. pw.format("<TR ALIGN=RIGHT><TD>%d<TD>%.1f%n", f, c);
  16. }
  17. pw.println("</TABLE>");
  18. pw.close();
  19. }
  20. }
Runtime error #stdin #stdout #stderr 0.04s 4386816KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.io.FileNotFoundException: temperature.html (Permission denied)
	at java.io.FileOutputStream.open0(Native Method)
	at java.io.FileOutputStream.open(FileOutputStream.java:270)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
	at java.io.FileWriter.<init>(FileWriter.java:63)
	at PrintHTMLTable.main(Main.java:11)