List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:Main.java
static boolean isCvv4Length(String cardNumber) { for (String bin : CVV4_BINS) { if (cardNumber.startsWith(bin)) { return true; }/*from w w w . java 2 s. com*/ } return false; }
From source file:Main.java
public static void openUrl(Context context, String url) { String urlLower = url.toLowerCase(); if (!urlLower.startsWith("http")) url = "http://" + url; Uri uri = Uri.parse(url);//from w w w. j ava2s. c o m Intent i = new Intent(Intent.ACTION_VIEW, uri); context.startActivity(i); }
From source file:com.google.infrastructuredmap.MapAndMarkdownExtractorMain.java
private static InputStream openStream(String path) throws IOException { if (path.startsWith("http:") || path.startsWith("https:")) { URL url = new URL(path); return new BufferedInputStream(url.openStream()); }//from w w w . java2s. c o m return new BufferedInputStream(new FileInputStream(path)); }
From source file:Main.java
/** * <p>Return subMap from target Map where the key start with appointing keyPrefix, subMap's remove keyPrefix</p> * <p>subMap([key1:value1,key21:value21,key22:value22], new HashMap(), key2) return [1:value21,2:value22]</p> * @param sourceMap//from ww w. j a v a 2 s . c o m * @param targetMap * @param keyPrefix * @return */ public static <E extends Object> Map<String, E> subMap(Map<String, E> sourceMap, Map<String, E> targetMap, String keyPrefix) { Set<Map.Entry<String, E>> entrys = sourceMap.entrySet(); for (Map.Entry<String, E> entry : entrys) { String key = entry.getKey(); if (key != null && key.startsWith(keyPrefix)) { targetMap.put(key.replace(keyPrefix, ""), entry.getValue()); } } return targetMap; }
From source file:Main.java
/** * {@link Type#toString()} value is the fully qualified class name prefixed * with {@link ReflectionUtils#TYPE_NAME_PREFIX}. This method will substring it, for it to be eligible * for {@link Class#forName(String)}.//from w ww.j av a2s . c om * * @param type the {@code Type} value whose class name is needed. * @return {@code String} class name of the invoked {@code type}. * * @see {@link ReflectionUtils#getClass()} */ public static String getClassName(Type type) { if (type == null) { return ""; } String className = type.toString(); if (className.startsWith(TYPE_CLASS_NAME_PREFIX)) { className = className.substring(TYPE_CLASS_NAME_PREFIX.length()); } else if (className.startsWith(TYPE_INTERFACE_NAME_PREFIX)) { className = className.substring(TYPE_INTERFACE_NAME_PREFIX.length()); } return className; }
From source file:Main.java
private static boolean shouldSkipClass(final Class<?> clazz) { final String clsName = clazz.getName(); return Object.class.equals(clazz) || clsName.startsWith("java.") || clsName.startsWith("javax.") || clsName.startsWith("android.") || clsName.startsWith("com.android."); }
From source file:Main.java
public static int getProvider(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String IMSI = telephonyManager.getSubscriberId(); if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) { return CHINA_MOBILE; } else if (IMSI.startsWith("46001")) { return CHINA_UNICOM; } else if (IMSI.startsWith("46003")) { return CHINA_TELECOM; }/* w w w. j av a 2 s . c o m*/ return PROVIDER_UNKNOWN; }
From source file:Main.java
public static ArrayList<String> retrieveLinks(String text) { ArrayList<String> links = new ArrayList<String>(); String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(text);//from w w w . jav a2 s .co m while (m.find()) { String urlStr = m.group(); if (urlStr.startsWith("(") && urlStr.endsWith(")")) { char[] stringArray = urlStr.toCharArray(); char[] newArray = new char[stringArray.length - 2]; System.arraycopy(stringArray, 1, newArray, 0, stringArray.length - 2); urlStr = new String(newArray); System.out.println("Finally Url =" + newArray.toString()); } System.out.println("...Url..." + urlStr); links.add(urlStr); } return links; }
From source file:Main.java
public static String resolveRelativePath(final String href, final String base) { if (href.startsWith("/")) { return href; }//ww w .ja v a 2 s. c o m return removeExtraSlashes(resolveBasePath(base) + "/" + href); }
From source file:Main.java
/** * Returns true if any String in the collections starts with the prefix * * @param stringList the list of values//from www.ja v a 2s.c o m * @param prefix the value being searched for * @return true if any String in the collections starts with the prefix */ public static boolean startsWith(Collection<String> stringList, String prefix) { if (isEmpty(stringList)) { return false; } for (String stringItem : stringList) { if (stringItem.startsWith(prefix)) { return true; } } return false; }