Page 648 - Introduction to Programming with Java: A Problem Solving Approach
P. 648
614 Chapter 15 Files
}
// end main
}
// end try
// First line used for title and header elements
line = fileIn.nextLine();
if (line == null)
{
}
else
{
}
// end else
System.out.println(filenameIn + " is empty.");
// Write the top of the HTML page.
fileOut.println("<html>");
fileOut.println("<head>");
fileOut.println("<title>" + line + "</title>");
fileOut.println("</head>");
fileOut.println("<body>");
fileOut.println("<h1>" + line + "</h1>");
while (fileIn.hasNextLine())
{
}
// end while
line = fileIn.nextLine();
// Blank lines generate p tags.
if (line.isEmpty())
Apago PDF Enhancer
fileOut.println("<p>");
} // end if
{
else
{
}
fileOut.println(line);
// Write ending HTML code.
fileOut.println("</body>");
fileOut.println("</html>");
fileIn.close();
fileOut.close();
catch (FileNotFoundException e)
{
System.out.println("Error: " + e.getMessage());
} // end catch
} // end class HTMLGenerator
Figure 15.6b HTMLGenerator program—part B