remove Ending Slash - Java java.lang

Java examples for java.lang:String End

Description

remove Ending Slash

Demo Code

import java.util.Random;

public class Main{

    public static void main(String[] argv){
        String baseUrl = "java2s.com/";
        System.out.println(removeEndingSlash(baseUrl));
    }// ww  w.j a v  a 2s.  c  o m
    public static String removeEndingSlash(String baseUrl) {
        if (baseUrl.endsWith("/")) {
            baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
        }
        return baseUrl;
    }

}

Related Tutorials