text to html conversion

Y

Yashwant

I want some information and documentation about how to convert text to
html using java? can anyone please help..
 
M

Mitja Trampus

Yashwant said:
I want some information and documentation about how to convert text to
html using java? can anyone please help..
Google JSP (java server pages) and/or Tomcat if you want it
done on the fly. I guess there are other options still.
If you just want to create html files as such, I don't see
what special instruction you could use. Grab the text, add
html tags and write into a file.
 
A

Andy Dingley

I want some information and documentation about how to convert text to
html using java?

1) What are you trying to do ? A one-off conversion, with maybe an
update every few weeks or is this a continuing dynamic task ?

2) Why Java ? There are lots of techniques out there, don't tie
yourself into a particular one before you're forced to.

3) What is "text" ? Is this simply plain text? Does it have paragraph
breaks in it (such as a blank line)? Or does it have some attempt at
full formatting in it?


If this was a one-off, then I'd probably do it with Perl because it's
simple and convenient. In the simplest case you just need to write out a
standard header and footer (probably best to read this from a template
file) and then insert the text file into the middle of it. You use Perl
rather than SSI because there's probably a regex in there that
recognises a blank line and turns it into </p><p> markup.

If it's a dynamic case, then look at what you can get hosted on the
server you need to use. This is more likely to be PHP than Java and the
problem is so trivial that you could do it with any server-side
scripting tool.
 
T

Toby Inkster

Yashwant said:
I want some information and documentation about how to convert text to
html using java?

My Java is a little rusty, but...

class TextToHTML
{
private String starttag = "\n<pre>";
private String finaltag = "</pre>\n";

public String convert (String text)
{
String html;

html = text.replaceAll("&", "&amp;");
html = html.replaceAll("<", "&lt;");

return starttag + html + finaltag;
}
}
 
T

Toby Inkster

Andy said:
You use Perl rather than SSI because there's probably a regex in there
that recognises a blank line and turns it into </p><p> markup.

s/^\s*$/<\/p><p>/g;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top