List of usage examples for java.lang String contains
public boolean contains(CharSequence s)
From source file:Main.java
public static boolean uninstallThroughCommand(String packageName) { String[] args = { "pm", "uninstall", packageName }; String result = executeCommand(args); return result.contains("Success"); }
From source file:Main.java
public static boolean installThroughCommand(String apkAbsolutePath) { String[] args = { "pm", "install", "-r", apkAbsolutePath }; String result = executeCommand(args); return result.contains("Success"); }
From source file:fr.vberetti.cassandra.metamodel.generation.TemplateUtil.java
private static String normalize(String raw, CaseFormat destination, boolean lowerCase) { if (isBlank(raw)) { return raw; }/*from w w w . j ava 2s . c om*/ String toNormalize = raw.trim(); if (toNormalize.contains(" ")) { toNormalize = toNormalize.replaceAll(" ", "_"); } if (toNormalize.contains("_") && toNormalize.contains("-")) { toNormalize = toNormalize.replaceAll("-", "_"); } CaseFormat original = lowerCase ? UPPER_CAMEL : LOWER_CAMEL; if (toNormalize.contains("_")) { original = lowerCase ? UPPER_UNDERSCORE : LOWER_UNDERSCORE; } else if (toNormalize.contains("-")) { original = LOWER_HYPHEN; } return original.to(destination, toNormalize); }
From source file:Main.java
public static Date parseRFC822Date(String date) { Date result = null;/*from ww w . jav a2s .co m*/ if (date.contains("PDT")) { date = date.replace("PDT", "PST8PDT"); } if (date.contains(",")) { // Remove day of the week date = date.substring(date.indexOf(",") + 1).trim(); } SimpleDateFormat format = RFC822Formatter.get(); for (int i = 0; i < RFC822DATES.length; i++) { try { format.applyPattern(RFC822DATES[i]); result = format.parse(date); break; } catch (ParseException e) { e.printStackTrace(); } } if (result == null) { Log.e(TAG, "Unable to parse feed date correctly"); } return result; }
From source file:com.crushpaper.CommandLineUtil.java
/** * Returns the array of with double quotes around any argument with spaces * in it so it can be run from the command line. *///from w w w .ja v a2s. c om static public String getArgsForCopyAndPaste(String[] args) { String[] result = new String[args.length]; for (int i = 0; i < args.length; ++i) { String arg = args[i]; result[i] = arg.contains(" ") ? "\"" + arg + "\"" : arg; } return StringUtils.join(result, " "); }
From source file:Main.java
public static boolean isXposedExists(Throwable thr) { StackTraceElement[] stackTraces = thr.getStackTrace(); for (StackTraceElement stackTrace : stackTraces) { final String clazzName = stackTrace.getClassName(); if (clazzName != null && clazzName.contains("de.robv.android.xposed.XposedBridge")) { return true; }/* w w w . ja va 2 s . c o m*/ } return false; }
From source file:Main.java
public static String quote(String value) { if (value != null) { if (value.contains("'")) { if (value.contains("\"")) { // We've got something perverse like [["It's back!"]] (ie a mix of single and double quotes!) StringBuilder sb = new StringBuilder("concat("); StringTokenizer st = new StringTokenizer(value, "'\"", true); while (st.hasMoreTokens()) { sb.append(quote(st.nextToken())); if (st.hasMoreTokens()) { sb.append(", "); }/* w w w . j a va 2 s . c o m*/ } sb.append(")"); return sb.toString(); } else { return '"' + value + '"'; } } else { return "'" + value + "'"; } } return value; }
From source file:com.milaboratory.util.GlobalObjectMappers.java
public static String toOneLine(Object object) throws JsonProcessingException { String str = GlobalObjectMappers.ONE_LINE.writeValueAsString(object); if (str.contains("\n")) throw new RuntimeException("Internal error."); return str;//www. j a v a2s. co m }
From source file:Main.java
public static String getMimeType(String url) { String mime = null;/*from w w w.ja v a 2s. c o m*/ int dot = url.lastIndexOf('.'); if (url.contains(".m3u8")) { mime = "video/mp4"; return mime; } if (dot >= 0) mime = (String) theMimeTypes.get(url.substring(dot + 1).toLowerCase()); if (mime == null) mime = "application/octet-stream"; return mime; }
From source file:Main.java
public static Object xmlToBean(Node beanNode) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { String className = beanNode.getNodeName(); System.out.println(className); Class clazz = Class.forName(className); Object bean = clazz.newInstance(); NodeList fieldNodeList = beanNode.getChildNodes(); for (int i = 0; i < fieldNodeList.getLength(); i++) { Node fieldNode = fieldNodeList.item(i); if (fieldNode.getNodeType() == Node.ELEMENT_NODE) { String fieldName = fieldNode.getNodeName(); if (!fieldName.contains(".")) { String getName = analyzeMethodName(fieldName, "get"); String setName = analyzeMethodName(fieldName, "set"); System.out.println(setName); clazz.getMethod(setName, clazz.getMethod(getName).getReturnType()).invoke(bean, fieldNode.getTextContent()); }/*from w w w .j ava 2s. co m*/ } } System.out.println(bean); return bean; }