Source Code : Printing an HTML Table

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Printing an HTML Table

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;

public class HTMLDemo {

  public static void main(String[] a) throws IOException {
    PrintWriter pw = new PrintWriter(new FileWriter("test.html"));
    DecimalFormat ff = new DecimalFormat("#0"), cf = new DecimalFormat(
        "0.0");
    pw.println("<TABLE BORDER><TR><TH>Fahrenheit<TH>Celsius</TR>");
    for (double f = 100; f <= 400; f += 10) {
      double c = 5 * (f - 32) / 9;
      pw.println("<TR ALIGN=RIGHT><TD>" + ff.format(f) + "<TD>"
          + cf.format(c));
    }
    pw.println("</TABLE>");
    pw.close(); // Without this, the output file may be empty
  }
}
           
       

Thank with us