Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { private static String escapeHTML(final String content) { String escaped = content.replace("&", "&"); escaped = escaped.replace("<", "<"); escaped = escaped.replace(">", ">"); escaped = escaped.replace("\r\n", "\n"); escaped = escaped.replace("\r", "\n"); escaped = escaped.replace("\n", "<br/>"); return escaped; } }