Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Returns the body part of the given HTML markup.
     */
    public static String getBodyMarkup(String markup, boolean replaceLinefeeds) {
        String lowerCase = markup.toLowerCase();
        int bodyStart = lowerCase.indexOf("<body>");

        if (bodyStart >= 0) {
            bodyStart += 7;
            int bodyEnd = lowerCase.lastIndexOf("</body>");

            if (bodyEnd > bodyStart) {
                markup = markup.substring(bodyStart, bodyEnd).trim();
            }
        }

        if (replaceLinefeeds) {
            markup = markup.replaceAll("\n", "<br>");
        }

        return markup;
    }

    /**
     * Returns the index of the given object in the given array of -1 if the
     * object is not contained in the array.
     */
    public static int indexOf(Object[] array, Object obj) {
        if (obj != null && array != null) {
            for (int i = 0; i < array.length; i++) {
                if (array[i] == obj) {
                    return i;
                }
            }
        }

        return -1;
    }
}