I have a text file of a story written out as each line of the story is one line, and I'm trying to write it to an HTML file using Java. I am unsure of how to do this, all I know is that I have to create a File object for the text file and a File object for the HTML file, and then open a printstream. But I'm still confused as to how to write from the input file to the output file using the printstream?
EDIT:
Certain lines need to have certain HTML tags, for example the top line of the textfile should have a header file, and then certain lines in all capital letters should have a header file, and then every other line should be surrounded by
tags.
I don't know of an efficient way to do this. Here's what I have so far:
private static String topstring = "<!doctype html>" + "\n" + "<html>" +
"\n" + "<head>" + "\n" +
"<meta charset=\"utf-8\">" + "\n" +
"<title>My Web Page</title>" + "\n" +
"</head>"+ "<body>";
public static void main(String[] args) throws IOException {
File input = new File("story.txt");
Scanner sc = new Scanner(input);
File output = new File("newstory.html");
PrintStream print = new PrintStream(output);
print.println(top string);
And then after this I'm not sure what to do.