I have a program which consist of several classes. The program reads a pom file and parses the data and then writes the data to a static table. The issue I'm having is with writing my LIB file data to my table. In the HtmlDataTable Class Im trying to write the files that are read in the lib directory to the table. My table currently consist of 3 columns (missing jar files,Lib Directory files, and POM file data) currently Im only able to write the missing jar files data to my table. In the HtmlDataTable class there is a for statement where I write the missing jar file data to my table. Im also trying to write the contents of the Lib directory within this statement as well. This is where I'm having my issue. My other classes consist of a SAX parser which parses the xml file, a class that creates my static table and a class that compares the jar files in my lib directory to the jar files in my pom file. . Theres a lot of code so I included the parts I felt were useful. If needed I can include the other classes as well.
public class ReadPomFile extends DefaultHandler {
public static void main(String[] args) {
try {
// obtain a SAX based parser to parse XML document
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
// obtain object for SAX parser
SAXParser saxParser = saxParserFactory.newSAXParser();
// default handler for SAX handler class
// both methods are written in handler's body
DefaultHandler defaultHandler = new SaxHandler();
// parses the XML specified in the path and uses the supplied
// handler to parse the document
saxParser.parse("C:/test/lib/pom.xml", defaultHandler);
System.out.println("Pom.xml data is loaded into Memory");
FileDemo fileDemo = new FileDemo();
fileDemo.readLibDir("C:/test/lib");
Set<String> filenameSet=FileNameStorage.getdataSet();
System.out.printf("These files were not found in the Lib Directory:\n"+FileNameStorage.getdata());
HtmlDataTable datatable = new HtmlDataTable();
datatable.writehtmltable(filenameSet);
DataChart datachart = new DataChart();
} catch (Exception e) {
e.printStackTrace();
}
}
public class HtmlDataTable {
public static void writehtmltable(Set<String> filenameSet){
if (filenameSet == null)
return;
//creates table in the following path
File htmltable = new File("C:/test/Output.html");
try (BufferedWriter bw = new BufferedWriter(new FileWriter(htmltable))) {
//write html data table
bw.write(htmltop);
// "<th>POM File Data</TH> <TH>Lib Directory Files</TH> <TH>Missing Jarfiles</TH>";
for (String jarfilename:filenameSet){
String lines="<tr> <td> </td> <td> </td> </td> <td>"+ jarfilename + " </tr>";
String line="<tr> <td> </td> <td> </td> </td> <td>"+ jarfilename + " </tr>"; // to populate the lib file column
bw.write(lines);
}
bw.write(htmlbottom);
| } catch (IOException e) { |
| | | e.printStackTrace(); |
Message was edited by: 2801625
Added missing syntax