List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
/** * Constructs a path out of the pathElements. * /* w w w .j ava2 s . c o m*/ * @param pathElements * the strings to connect. They can have "/" in them which will be de-duped in the result, if necessary. * @return * the path that was constructed. */ public static String buildPath(String... pathElements) { StringBuilder result = new StringBuilder("/"); for (String pathElement : pathElements) { result.append(pathElement).append('/'); } String returnValue = result.toString().replaceAll("/+", "/"); if (returnValue.endsWith("/")) { returnValue = returnValue.substring(0, returnValue.length() - 1); } return returnValue; }
From source file:org.trustedanalytics.metadata.parser.api.Metadata.java
private static String buildTargetUri(String storeId, String idInObjectStore) { if (storeId.endsWith("/")) { return storeId + idInObjectStore; }//from w w w. j av a 2 s .c o m return storeId + "/" + idInObjectStore; }
From source file:cz.muni.fi.pa165.creatures.rest.client.CreaturesRESTClient.java
/** * This method discards all slashes at the end of the URI address. We do not * need to add one because care is taken of it in the business code itself. * * @param uri URI to normalize/* ww w. j a v a 2 s .c om*/ * @return normalized URI */ private static String normalizeURI(String uri) { while (uri.endsWith("/")) { uri = uri.substring(0, uri.length() - 1); } return uri + "/"; }
From source file:Main.java
public static String trimQuotes(String s) { if (null != s && s.length() > 1) { if (s.startsWith("\"\\\"") && s.endsWith("\\\"\"")) { Log.d("MagnetUtils", "String " + s + " starting with \\\""); s = s.substring(3, s.length() - 3); } else if (s.startsWith("\"") && s.endsWith("\"")) { s = s.substring(1, s.length() - 1); }/*w w w. ja va 2 s . c om*/ } return s; }
From source file:AIR.Common.Web.UrlHelper.java
public static String getBase() { String contextPath = Server.getContextPath(); if (!contextPath.endsWith("/")) contextPath = contextPath + "/"; return contextPath; }
From source file:edu.uga.cs.fluxbuster.utils.DomainNameUtils.java
/** * Returns a copy of the domain name with leading and trailing * dots removed.// ww w.ja v a 2 s . co m * * @param domainname the original domain name * @return the stripped of dots */ public static String stripDots(String domainname) { String retval = domainname; if (retval.endsWith(".")) { retval = retval.substring(0, retval.length() - 1); } if (retval.startsWith(".")) { retval = retval.substring(1, retval.length()); } return retval; }
From source file:Main.java
public static String getGfycatId(String in) { Uri uri = Uri.parse(in);/* w ww. j a v a 2s .com*/ final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.endsWith("gfycat.com") == true) { List<String> paths = uri.getPathSegments(); if (paths.size() == 1) { return paths.get(0); } else if (paths.size() == 2) { return paths.get(1); } } return null; }
From source file:com.github.zhanhb.ckfinder.connector.utils.PathUtils.java
/** * Adds slash character at the end of String provided as parameter. The slash * character will not be added if parameter is empty string or ends with * slash.//from ww w. j a v a 2 s .c o m * * @param string string to add slash character to * @return String with slash character at the end, {@code null} or empty * string. */ public static String addSlashToEnd(String string) { if (string == null || string.endsWith("/")) { return string; } return string.concat("/"); }
From source file:com.alliander.osgp.adapter.protocol.oslp.device.FirmwareLocation.java
private static String cleanUpPath(final String path) { String cleanPath = path; if (cleanPath.endsWith("/")) { cleanPath = cleanPath.substring(0, cleanPath.length() - 1); }/*from w w w.j a va 2 s. c om*/ if (cleanPath.startsWith("/")) { cleanPath = cleanPath.substring(1); } return cleanPath; }
From source file:Main.java
/** * Zip the subdirectory and exclude already zipped files * @param path/* w w w .j a v a 2 s. c om*/ * @param srcFolder * @param zip * @param includeFullPath * @throws java.io.IOException */ static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, boolean includeFullPath) throws IOException { File folder = new File(srcFolder); for (String fileName : folder.list()) { if (path.equals("") && !fileName.endsWith(".zip")) { if (includeFullPath) { addFileToZip(folder.toString(), srcFolder + "/" + fileName, zip); } else { addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip); } } else if (!fileName.endsWith(".zip")) { addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip); } } }