Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-conversion Convert Text to HTML

Related Tutorials


 
 

Share on Google+Share on Google+

Convert Text to HTML

Advertisement
In this section, you will learn how to convert text to html file.

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[]){
  try{
  FileOutputStream fs = new FileOutputStream("TextToHTML.html");
  OutputStreamWriter out = new OutputStreamWriter(fs);
  System.out.println("This is text to html convertor program:");
  out.write("<html>");  
  out.write("<head>")
  out.write("<title>");  
  out.write("Convert text to html");
  out.write("</title>");  
  out.write("</head>");
  out.write("<body>");
  out.write("Welcome to html<br>This query through the java code");
  out.write("<br>Welcome to Roseindia<br>This is good site");
  out.write("</body>");
  out.write("</html>");
  out.close();
  }
  catch (IOException e){
  System.err.println(e);
  }
  }
}

 Download of this program:

Command prompt Output of this program.

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

Output of this program.

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 10, 2007

Related Tutorials

Discuss: Convert Text to HTML   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com