Here you can find the source of chopScheme(String path)
Parameter | Description |
---|---|
path | a URL path. |
public static String chopScheme(String path)
//package com.java2s; /**/*from ww w. ja v a2s . co m*/ * This class holds various utility methods. * * @author Yanick Duchesne * <dl> * <dt><b>Copyright: </b> * <dd>Copyright © 2002-2003 <a * href="http://www.sapia-oss.org">Sapia Open Source Software </a>. All * Rights Reserved.</dd> * </dt> * <dt><b>License: </b> * <dd>Read the license.txt file of the jar or visit the <a * href="http://www.sapia-oss.org/license.html">license page </a> at the * Sapia OSS web site</dd> * </dt> * </dl> */ public class Main { /** * Chops the scheme/protocol from the given URL path and returns the path * without the scheme. * * @param path * a URL path. * @return the path without the scheme, or the given path, if it has no * scheme. */ public static String chopScheme(String path) { int idx = path.indexOf(":"); if (idx >= 0) { String toReturn = path.substring(idx + 1); if (toReturn.startsWith("//")) { toReturn = toReturn.substring(1); } return toReturn; /*if(toReturn.charAt(0) != '/'){ return new StringBuffer('/').append(toReturn).toString(); if(File.separator.equals("/") && (toReturn.charAt(0) != '/')) { return File.separator + toReturn; } else if(File.separator.equals("\\") && (toReturn.charAt(0) != '/')) { return '/' + toReturn; } else { return toReturn; }*/ } return path; } }