Java tutorial
//package com.java2s; /** * ownCloud Android client application * * Copyright (C) 2012 Bartek Przybylski * Copyright (C) 2015 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ public class Main { public static final String WEBDAV_PATH_4_0_AND_LATER = "/remote.php/webdav"; private static final String ODAV_PATH = "/remote.php/odav"; public static String trimWebdavSuffix(String url) { while (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } int pos = url.lastIndexOf(WEBDAV_PATH_4_0_AND_LATER); if (pos >= 0) { url = url.substring(0, pos); } else { pos = url.lastIndexOf(ODAV_PATH); if (pos >= 0) { url = url.substring(0, pos); } } return url; } }