how to club html code in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jank
    New Member
    • Aug 2007
    • 7

    #1

    how to club html code in java

    I wrote java file to send mass email. But mail contains images, text format .
    Is it possible to club html code in java file?
    thanks
  • kreagan
    New Member
    • Aug 2007
    • 153

    #2
    are you going to display this HTML code in an swing application? Because you can do that.

    http://java.sun.com/javase/6/docs/api/
    http://java.sun.com/javase/6/docs/api/

    http://java.sun.com/javase/6/docs/api/

    But what do you want to do with this html code? What do you mean by club? By club you mean how PHP can process HTML code, I highly doubt you will find any way to do that.

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      i haven't used java for awhile now but, i hope this helps.

      can't u set the contentType to "text/html"? that way when it is emailed the receiver's client will receive that header info and parse the email as if it were an html document.

      i know this can be done in servlets, so i hope it can be here too.

      good luck

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        I don't know, if it helps, but you can certainly print HTML by using a PrintWriter like this:

        Code:
        // Create a new PrintWriter, which writes to a file called "test.htm" in the present directory
        PrintWriter writer = new PrintWriter(new FileOutputStream("test.htm"));
        // Write HTML-Code to the file
        writer.print("<html>" +
        	"<head><title>Write to HTML-File</title></head>" +
        	"<body>" +
        	"This works!" +
        	"</body>" +
        	"</html>");
        // Close the file (otherwise it will be empty)
        writer.close();
        Of course, the PrintWriter can recieve a totally different OutputStream.

        Comment

        • gaya3
          New Member
          • Aug 2007
          • 184

          #5
          Originally posted by jank
          I wrote java file to send mass email. But mail contains images, text format .
          Is it possible to club html code in java file?
          thanks

          Hi,
          Following code may help u...

          import java.io.*;
          class Htmlinjava
          {


          public static void main (String args[])
          {

          FileOutputStrea m fout;

          try
          {

          fout = new FileOutputStrea m ("myfile.html") ;


          new PrintStream(fou t).println ("<html><body>" +"Hello World!"+"</body></html>");


          fout.close();
          }

          catch (IOException e)
          {
          System.err.prin tln ("Unable to write to file");

          }

          }

          Comment

          Working...