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 getPageName(String link, boolean cutQueries) {
        String s = link.trim();
        if (s.endsWith("/")) {
            s = s.substring(0, s.length() - 1);
        }
        int i2 = -1;
        if (cutQueries)
            i2 = link.indexOf('?');
        if (i2 < 0)
            i2 = s.length();

        int i1 = s.lastIndexOf('/', i2) + 1;
        //      int i2 = -1;
        //      if (cutQueries)
        //         i2 = link.indexOf('?');
        //      if (i2 < 0)
        //         i2 = s.length();
        if (i1 < 0)
            i1 = 0;
        return s.substring(i1, i2);
    }

    public static String getPageName(String link) {
        return getPageName(link, false);
    }
}