Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.support.annotation.NonNull;

public class Main {
    @NonNull
    private final static String HTML_CONTENT = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n"
            + "    <meta charset=\"utf-8\">\n" + "    <link rel=\"stylesheet\" href=\"./styles/%s\">\n"
            + "</head>\n" + "<body onload=\"prettyPrint()\">\n" + "<pre class=\"prettyprint linenums\">%s</pre>\n"
            + "<script src=\"./js/prettify.js\"></script>\n" + "</body>\n" + "</html>";

    @NonNull
    public static String generateContent(@NonNull String source) {
        return String.format(HTML_CONTENT, getStyle(), getFormattedSource(source));
    }

    @NonNull
    private static String getStyle() {
        return "prettify.css";
    }

    @NonNull
    private static String getFormattedSource(@NonNull String source) {
        return source.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
    }
}