Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static String toHtml(String string) {
        if (string == null)
            return "";
        string = string.replaceAll("&", "&");
        string = string.replaceAll("\"", """);
        string = string.replaceAll("<", "&lt;");
        string = string.replaceAll(">", "&gt;");
        // string = string.replaceAll("\r\n", "\n");
        string = string.replaceAll("\n", "<br>\n");
        string = string.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
        string = string.replaceAll(" ", "&nbsp;");
        return string;
    }
}