Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * To html.
     * 
     * @param src
     *            the src
     * @return the string
     */
    public static String ToHtml(String src) {
        src = src.replace("\r\n", "<br>");
        src = src.replace("\n", "<br>");
        src = src.replace("\r", "<br>");
        src = src.replace(" ", "&nbsp;");
        ToJavascriptText(src);
        return src;
    }

    /**
     * To javascript text.
     * 
     * @param src
     *            the src
     * @return the string
     */
    public static String ToJavascriptText(String src) {
        src = src.replace("\\", "\\\\");
        src = src.replace("\n", "\\n");
        src = src.replace("\r", "\\r");
        src = src.replace("'", "\\'");
        src = src.replace("\"", "\\\"");
        src = src.replace("\b", "\\b");
        src = src.replace("\t", "\\t");
        src = src.replace("\f", "\\f");
        return src;
    }
}