0

I want to write a java program that asks the user for information like name, age , etc. Then take that information and make an HTML document on my computer with the information in it. I don't know where to start with making it a web page. Here is my code so far:

import javax.swing.JOptionPane;
public class WritesHTML{
public static void main(String[] args){
    String firstName = JOptionPane.showInputDialog("Enter first name:");
    String lastName = JOptionPane.showInputDialog("Enter last name:");
    String age = JOptionPane.showInputDialog("Enter age:");
    String occupation = JOptionPane.showInputDialog("occupation:");

    int numAge = Integer.parseInt(age);

    }
}
karthikr
  • 97,368
  • 26
  • 197
  • 188

1 Answers1

0

HTML document contains simple text, it's only difference from a standard text file is in the .html extension. What you need to do is piece the information about the user together as a text, either String, StringBuffer, or anything you can output into a file. The text forms the HTML source code of your new page. Then you need to create a new File object and dump the text into the file using a FileStream. After you close the stream, the text will be added into your HTML file and that's your document.

I suggest you have a look at some tutorials about files and file streams for more info about how to piece this together, as it is too much to cover in detail in a single post.

Warlord
  • 2,798
  • 16
  • 21