How to Avoid unnessecary HTML Code while generating HTML for Mail or HTML File
Method1
DataOutputStream dosReport = new DataOutputStream(new FileOutputStream(fileName));
dosReport.wrtiteBytes("<table><thead>");
dosReport.writeBytes("<th>Column1</th>");
dosReport.writeBytes("<th>Column2</th>");
dosReport.writeBytes("<th>Column3</th>");
dosReport.writeBytes("<th>Column4</th>");
dosReport.writeBytes("<th>Column5</th>");
dosReport.writeBytes("<th>Column6</th>");
dosReport.writeBytes("<th>Column7</th>");
dosReport.writeBytes("<th>Column8</th>");
dosReport.writeBytes("<th>Column9</th>");
dosReport.wrtiteBytes("</thead>");
Method2
Replace with Below
DataOutputStream dosReport = new DataOutputStream(new FileOutputStream(fileName));
dosReport.wrtiteBytes("<table><thead>");
String[] columns = {"Column1", "Column2", "Column3",
"Column4", "Column5", "Column6",
"Column7", "Column8", "Column9"};
for(int i = 0; i < columns.length; i++)
dosReport.writeBytes("<th>" + columns[i] +"</th>");
dosReport.wrtiteBytes("</thead>");
Disadvantage:
In the Method1 you have fine control over individual cell(tds) so you can add properties like align, individual stylings can be applied.