[an error occurred while processing this directive]

Convert Text to HTML


In this section, We are discussing the conversion of text into html file .This program functionally provides you converting text to html file by using FileOutputStream. The FileOutputStream() is a constructor.

Code Description:

In this program, you will also learn about the OutputStreamWriter. The OutputStreamWriter is a constructor. The FileOutputStream create an output file stream to write to the file with the specified name.

Here is the code of this program:

import java.math.*;
import java.io.*;

public class TextToHTML
  public static void main(String arg[]){
      FileOutputStream fs = new FileOutputStream("TextToHTML.html");
      OutputStreamWriter out = new OutputStreamWriter(fs);
      System.out.println("This is text to html convertor program:");
      out.write("Convert text to html");
      out.write("Welcome to html<br>This query through the java code");
      out.write("<br>Welcome to Roseindia<br>This is good site");
    catch (IOException e){

 Download of this program:

Command prompt Output of this program.

C:\corejava>java TextToHTML
This is text to html convertor program:

Output of this program.



[an error occurred while processing this directive]