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 replaceAll(String url, String source, String replacement) {
        return replaceAndEndnote(url, source, replacement, "(", ".");
    }

    public static String replaceAndEndnote(String text, String holderString, String replacement, String noteTag,
            String noteSplit) {
        StringBuilder note = new StringBuilder();
        note.append(noteTag);

        String tmp = new String(text);
        int start = 0;
        while ((start = tmp.indexOf(holderString, start)) >= 0) {
            note.append(start + noteSplit);
            start += holderString.length();
        }
        start = note.length() - noteSplit.length();
        if (note.substring(start).equals(noteSplit))
            note.delete(start, note.length());

        return text.replace(holderString, replacement) + note;
    }
}