List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
/** * Returns the content type for the given filePath. *//*from w ww. j ava2 s . c o m*/ public static String getContentTypeForFilePath(String filePath) { filePath = filePath.toLowerCase(); if (filePath.endsWith(".gif")) { return "image/gif"; } if (filePath.endsWith(".jpg") || filePath.endsWith(".jpeg")) { return "image/jpeg"; } if (filePath.endsWith(".png")) { return "image/png"; } if (filePath.endsWith(".apk")) { return "application/vnd.android.package-archive; charset=utf-8"; } if (filePath.endsWith(".zip")) { return "application/zip; charset=utf-8"; } if (filePath.endsWith(".keystore")) { return "application/octet-stream"; } // default return "text/plain; charset=utf-8"; }
From source file:Main.java
public static boolean isTop(String str) { boolean flag = false; if (!TextUtils.isEmpty(str) && str.startsWith("#") && str.endsWith("#") && str.length() >= 2) { flag = true;/*from w w w. j a v a2 s .c o m*/ } return flag; }
From source file:com.blacklocus.jres.strings.JresPaths.java
/** * @return fragments each appended with '/' if not present, and concatenated together *//* w w w. j av a2 s . co m*/ public static String slashed(String... fragments) { StringBuilder sb = new StringBuilder(); for (String fragment : fragments) { sb.append(StringUtils.isBlank(fragment) || fragment.endsWith("/") ? (fragment == null ? "" : fragment) : fragment + "/"); } return sb.toString(); }
From source file:Main.java
public static String deleteSpace(String str) { if (str.startsWith(" ")) { str = str.substring(1, str.length()).trim(); } else if (str.endsWith(" ")) { str = str.substring(0, str.length() - 1).trim(); }//from w ww . ja v a 2s .com return str; }
From source file:Main.java
public static String fileName(String path) { if (!isEmpty(path)) { // adapted from DropboxAPI.java v1.5.4 if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); }//from www .j a v a2 s.c o m int ind = path.lastIndexOf('/'); return path.substring(ind + 1, path.length()); } return ""; }
From source file:net.duckling.ddl.util.FileTypeUtils.java
public static boolean isClbDealImage(String fileName) { if (StringUtils.isEmpty(fileName)) { return false; }//from w ww . j a v a2s.co m String f = fileName.toLowerCase(); for (String suffix : pictureSuffix) { if (f.endsWith(suffix)) { return true; } } return false; }
From source file:com.wavemaker.commons.util.ConversionUtils.java
public static List<Resource> convertToResourceList(List<File> files) { List<Resource> resources = new ArrayList<Resource>(); for (File file : files) { String path = file.getAbsolutePath(); if (file.isDirectory() && !path.endsWith("/")) { path += "/"; }//ww w . java 2s . c o m resources.add(new FileSystemResource(path)); } return resources; }
From source file:asia.gkc.vneedu.utils.FileUtil.java
/** * /*from www. j a va2s . com*/ * * @param dir - * @return */ public static boolean buildDir(String dir) { if (dir.endsWith(File.separator)) return buildDir(new File(dir)); String path = dir.substring(0, dir.lastIndexOf(File.separator)); return buildDir(new File(path)); }
From source file:com.alliander.osgp.adapter.protocol.oslp.device.FirmwareLocation.java
private static String cleanUpDomain(final String domain) { String cleanDomain = domain; if (cleanDomain.endsWith("/")) { cleanDomain = cleanDomain.substring(0, cleanDomain.length() - 1); }/*from ww w . java 2s . c o m*/ if (cleanDomain.contains("://")) { cleanDomain = cleanDomain.substring(cleanDomain.indexOf("://") + 3); } return cleanDomain; }
From source file:Main.java
/** * Simply removes double-quotes from the beginning and end of given string * @param str//from ww w . java 2s . c o m * @return */ public static final String dequote(String str) { if (str.startsWith("\"")) str = str.substring(1); if (str.endsWith("\"")) str = str.substring(0, str.length() - 1); return str; }