Java Equivelant to PHP nl2br

R

rick.huby

Does Java have an equivalent of the rather handy PHP function nl2br
which replaces new lines with <br /> for nice use in websites?

I am sure it is nice and easy to just replace all of the \n or \r\n 's
with the <BR /> but with it being such a useful PHP thing I thought
that their might be a java version.

Thanks
 
R

rocha_dk

You could use the String method, replace. Like this:

StringName.replace("\n","<br>");

I think that is the easiest way to do it.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top