CSC 8310 Linguististics of Programming Languages
Dr. David Matuszek
Fall 1997, Villanova University

Second Java assignment: Simple text to HTML translator

In this assignment you are to write a Java application that reads in text from a file, translates it to (very simple) HTML, and writes it out to a second file. You do not need to know any HTML beyond what is described in this handout. This assignment is primarily an exercise in using Java I/O, plus a little string manipulation.

Your Java application should get the name of the text file to be processed from the command line. The name of the output file should be the same as that of the input file, but with a .html extension (or .htm, if you have only 8+3 filenames).

Your application should simply copy the input file to the output file, with the following modifications:

  1. The text should be embedded in HTML, as shown below.
  2. The first line of the input file should be written out twice: once as a title, and once as a header.
  3. Anywhere one of the three special characters &, <, and > appears in the text, it should be replaced by the corresponding HTML code, according to the table below. (Hint: use the StringBuffer class.)
  4. Any blank line should be replaced by a line containing <p> .

You should be able to check your output by viewing it in any Browser.

Here's the HTML you need:

      <title>Your title line goes here</title>
      <h1>Your header goes  here</h1>
      Your text goes here and may consist of many lines.

Please turn in:

  1. A listing of your application, your test input file, and your output file.
  2. A machine-readable copy of your application as a plain ASCII text file. This can be on a floppy, or you can e-mail it to me at .