Write code to trim After Last Slash
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s/.com/"; System.out.println(trimAfterLastSlash(str)); }/* w ww. j ava 2s .c om*/ public static String trimAfterLastSlash(String str) { if (str.lastIndexOf("/") > 0) { return str.substring(0, str.lastIndexOf("/")); } return str; } }