List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
private static final String determineMimeType(String location) { String s = location.toLowerCase().trim(); if (s.endsWith("png")) return "image/png"; if (s.endsWith("gif")) return "image/gif"; if (s.endsWith("jpg") || s.endsWith("jpeg")) return "image/jpeg"; return "image/gif"; // default }
From source file:Main.java
public static String addFileSeperatorToEndOfPath(String path) { if (path != null) { if (!path.endsWith(File.separator)) { return path += File.separator; } else {/*www.j ava 2 s . c o m*/ return path; } } else { return ""; } }
From source file:com.tyro.oss.pact.spring4.pact.consumer.PactPublisher.java
private static File[] findPactFiles(String pactFileRoot) { File pactFileRootDirectory = new File(pactFileRoot); if (!pactFileRootDirectory.exists() || !pactFileRootDirectory.isDirectory()) { throw new IllegalArgumentException(String.format( "Pact file root directory either does not exist, or is not a directory: %s", pactFileRoot)); }//from ww w . jav a 2 s . c om return pactFileRootDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith("_pacts.json"); } }); }
From source file:Main.java
public static String trimWebdavSuffix(String url) { String trimmedUrl = url; while (trimmedUrl.endsWith("/")) { trimmedUrl = trimmedUrl.substring(0, url.length() - 1); }//from w w w. j a v a2s.co m int pos = trimmedUrl.lastIndexOf(WEBDAV_PATH_4_0_AND_LATER); if (pos >= 0) { trimmedUrl = trimmedUrl.substring(0, pos); } else { pos = trimmedUrl.lastIndexOf(ODAV_PATH); if (pos >= 0) { trimmedUrl = trimmedUrl.substring(0, pos); } } return trimmedUrl; }
From source file:Main.java
/** * Find the end of this tag; there are two alternatives: <tag .../> or <tag ...> ... </tag> * @param htmlText some HTML text/*from w w w . j a va2 s .c o m*/ * @param tag the HTML tag * @param startPos the start position in the HTML text where the tag starts * @return the position just before the end of the tag or -1 if not found */ /*package*/static int findTagEnd(String htmlText, String tag, int startPos) { if (tag.endsWith(" ")) { tag = tag.substring(0, tag.length() - 1); } int length = htmlText.length(); char prevChar = 0; for (int i = startPos; i < length; i++) { char c = htmlText.charAt(i); if (c == '>') { if (prevChar == '/') { return i - 1; } break; } prevChar = c; } // We didn't find /> at the end of the tag so find </tag> return htmlText.indexOf("/" + tag, startPos); }
From source file:Main.java
/** * Returns true if the media type is recognized as the media type of some XML format. *//*from ww w .j a v a 2 s.com*/ public static boolean isXmlMediaType(String mediaType) { return xmlMediaTypes.contains(mediaType) || mediaType.endsWith("+xml"); }
From source file:com.ge.predix.acs.commons.web.UriTemplateUtils.java
public static String appendTrailingSlash(final String s) { if (!s.endsWith("/")) { return new StringBuilder(s).append("/").toString(); }//from w ww .j a v a 2 s . c om return s; }
From source file:Main.java
static public ArrayList<String> getSavedGestureNames(Context context) { ArrayList<String> gestureNames = new ArrayList<>(); File[] files = context.getFilesDir().listFiles(new FilenameFilter() { @Override/*from www . ja v a 2 s. c o m*/ public boolean accept(File dir, String filename) { return filename.endsWith(GESTURE_NAME_SUFFIX); } }); //return the files without the suffix for (File file : files) { gestureNames.add(file.getName().substring(0, file.getName().indexOf(GESTURE_NAME_SUFFIX))); } return gestureNames; }
From source file:Main.java
public static boolean checkApkIsExist(String apkSaveName) { boolean isExist = false; File directory = new File(DOWNLOADPATH); if (directory.exists()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { String fileName = files[i].getName(); if (fileName.endsWith(".apk")) { fileName = fileName.substring(0, fileName.length() - 4); if (fileName.equals(apkSaveName)) { isExist = true;/* www . j a v a2 s.c o m*/ break; } } } } return isExist; }
From source file:Main.java
public static String getWriteType(int writeType) { StringBuilder permissionStr = new StringBuilder(); String binaryString = Integer.toBinaryString(writeType); binaryString = String.format("%16s", binaryString).replace(' ', '0'); int len = binaryString.length(); //WRITE_TYPE_NO_RESPONSE (0x00000001) if (binaryString.charAt(len - 1) == '1') { permissionStr.append("NO_RESPONSE,"); }/*from w w w.j a v a 2s .c o m*/ //WRITE_TYPE_DEFAULT (0x00000002) if (binaryString.charAt(len - 2) == '1') { permissionStr.append("WRITE,"); } //WRITE_TYPE_SIGNED (0x00000004) if (binaryString.charAt(len - 3) == '1') { permissionStr.append("SIGNED,"); } String perStr = permissionStr.toString(); if (perStr.endsWith(",")) { perStr = perStr.substring(0, perStr.length() - 1); } return perStr; }