Due: Monday, October 28
40 pointsIn this assignment, you'll write a Java program which asks the user to enter the name of a plain text file. The program reads the file and then outputs an html version according to the guidelines provided.
The purpose of the assignment is to provide some practice reading and writing files as well as reinforcing what you've learned about handling Strings
If you're unfamiliar with the basics of HTML or need a refresher, you can learn more at w3schools.
The user should enter the name of an input file which ends ".txt". The output file should have the same name as the input file, except that instead of ending ".txt", it should end ".html"
We'll only be working with a very small part of HTML in this assignment. You're welcome to add more if you'd like, but at a minimum, the HTML output should begin:
<html>
<body>
and should end:
</body>
</html>
Other transformations from the input file to HTML should be done according to the following:
the program would output:#Big Important Point#
<h1>Big Important Point</h1>
<P>
(You do not have to close paragraphs with an XHTML-style closing paragraph tag </P>).
<ul>
<li>text following the '-'</li>
</ul>
So for example, if in the input file we see:
- turkey
- lettuce
- tomato
- little bit of mayo
Your program would output
<ul>
<li>turkey</li>
<li>lettuce</li>
<li>tomato</li>
<li>little bit of mayo</li>
</ul>
If the input file is:
#shanty#
Who lives in a pineapple under the sea?
Spongebob Squarepants
- absorbent
- yellow
- porous
is he, Spongebob Squarepants
The program would output:
<html>
<body>
<h1>shanty</h1>
<p>
Who lives in a pineapple under the sea?<br />
Spongebob Squarepants<br />
<p>
<ul>
<li> absorbent</li>
<li> yellow</li>
<li> porous</li>
</ul>
<p> is he, Spongebob Squarepants<br />
</body>
</html>
which, when rendered in a web browser, would look something like:
Who lives in a pineapple under the sea?
Spongebob Squarepants
is he, Spongebob Squarepants
Any text in the input file of the form [[X][Y]] should be treated as a hyperlink, where X is the URL, and Y is the text to display on the screen. For example, if X is http://www.cis.temple.edu/~jfiore/2024/fall/1068 and Y is class, your program should output a hyperlink that displays the text class, which when clicked takes the user to the page http://www.cis.temple.edu/~jfiore/2024/fall/1068.
You are not required to handle the possibility that one of these blocks begins and ends on different lines of the input file.
Remember that you are not required to handle FileNotFoundException using try-catch-finally blocks. We'll cover these later in the semester. For now, it is only necessary to add the clause throws FileNotFoundException to each function where you write new File or any function that calls a function that has a throws FileNotFoundException clause. You'll find examples of this in our classnotes.
For up to 5 extra credit points, define a new markup shortcut (for example, one that marks a region that should be bold or italicized, links to places in the same document, or others) and add it to your program.
For up to 5 extra credit points, write a JUnit test to test some function that you've written that is passed a string and returns a new string according to one of the transformation rules previously described.
Please upload your .java file to Canvas.
It's a good idea to confirm through the Canvas submission page that what you've intended to submit was uploaded. We will grade what you submit. If you submit a corrupted, empty, or otherwise incorrect file, this is what we'll grade. It is your responsibility to verify through the Canvas submission page that you've submitted the correct files and that they were uploaded properly.
Here's a Canvas tutorial on how to submit files.