List of usage examples for java.lang String toLowerCase
public String toLowerCase(Locale locale)
From source file:Main.java
/** * Get all device accounts having specified domain name. * @param context application context//from w w w. j av a 2s . c om * @param domain domain name used for filtering * @return List of account names that contain the specified domain name */ public static List<String> getDeviceAccountsWithDomain(final Context context, final String domain) { final ArrayList<String> retval = new ArrayList<String>(); final String atDomain = "@" + domain.toLowerCase(Locale.ROOT); for (final Account account : getAccounts(context)) { if (account.name.toLowerCase(Locale.ROOT).endsWith(atDomain)) { retval.add(account.name); } } return retval; }
From source file:Main.java
public static boolean isURI(String str) { if (str.indexOf(':') == -1) return false; str = str.toLowerCase(Locale.ENGLISH).trim(); if (!str.startsWith("http://") && !str.startsWith("https://") && !str.startsWith("ftp://")) return false; try {//from w w w. j ava2s .com URI uri = new URI(str); String proto = uri.getScheme(); if (proto == null) return false; if (proto.equals("http") || proto.equals("https") || proto.equals("ftp")) { if (uri.getHost() == null) return false; String path = uri.getPath(); if (path != null) { int len = path.length(); for (int i = 0; i < len; i++) { if ("?<>:*|\"".indexOf(path.charAt(i)) > -1) return false; } } } return true; } catch (Exception ex) { return false; } }
From source file:com.xiangzhurui.util.email.POP3Mail.java
public static final void printMessageInfo(BufferedReader reader, int id) throws IOException { String from = ""; String subject = ""; String line; while ((line = reader.readLine()) != null) { String lower = line.toLowerCase(Locale.ENGLISH); if (lower.startsWith("from: ")) { from = line.substring(6).trim(); } else if (lower.startsWith("subject: ")) { subject = line.substring(9).trim(); }/* w w w.j a v a2s .co m*/ } System.out.println(id + " From: " + from + " Subject: " + subject); }
From source file:examples.mail.POP3Mail.java
public static final void printMessageInfo(BufferedReader reader, int id) throws IOException { String from = ""; String subject = ""; String line; while ((line = reader.readLine()) != null) { String lower = line.toLowerCase(Locale.ENGLISH); if (lower.startsWith("from: ")) { from = line.substring(6).trim(); } else if (lower.startsWith("subject: ")) { subject = line.substring(9).trim(); }//from w w w . j a v a2 s.c o m } System.out.println(Integer.toString(id) + " From: " + from + " Subject: " + subject); }
From source file:com.spotify.styx.model.Schedule.java
private static WellKnown toWellKnown(String expression) { switch (expression.toLowerCase(Locale.US)) { case "@hourly": case "hourly": case "hours": return WellKnown.HOURLY; case "@daily": case "daily": case "days": return WellKnown.DAILY; case "@weekly": case "weekly": case "weeks": return WellKnown.WEEKLY; case "@monthly": case "monthly": case "months": return WellKnown.MONTHLY; case "@annually": case "annually": case "@yearly": case "yearly": case "years": return WellKnown.YEARLY; default://from w w w. j a va2 s . co m return WellKnown.UNKNOWN; } }
From source file:com.fiveamsolutions.nci.commons.util.UsernameHolder.java
/** * Sets the username for the current thread, converting the username to all lowercase. * @param user the user to set for the current thread */// w w w.j a va 2s. c o m public static void setUser(String user) { usernameThreadLocal.set((user == null) ? null : user.toLowerCase(Locale.US)); }
From source file:com.sk89q.craftbook.sponge.mechanics.area.complex.CopyManager.java
/** * Load a copy from disk. This may return a cached copy. If the copy is not cached, * the file will be loaded from disk if possible. If the copy * does not exist, an exception will be raised. An exception may be raised if the file exists but cannot be read * for whatever reason.//from ww w .java 2 s. com * * @param world The world to load it into * @param namespace The namespace * @param id The area ID * * @return The CuboidCopy * * @throws CuboidCopyException Thrown if the data was invalid */ public static CuboidCopy load(World world, String namespace, String id) throws CuboidCopyException { id = id.toLowerCase(Locale.ENGLISH); File folder = new File(new File(CraftBookPlugin.inst().getWorkingDirectory(), "areas"), namespace); return CuboidCopy.load(new File(folder, id + getFileSuffix()), world); }
From source file:Main.java
/** * Read the first line of "/proc/cpuinfo" file, and check if it is 64 bit. *//*from ww w . ja va 2 s . c o m*/ public static boolean isCPUInfo64() { File cpuInfo = new File(PROC_CPU_INFO_PATH); if (cpuInfo != null && cpuInfo.exists()) { InputStream inputStream = null; BufferedReader bufferedReader = null; try { inputStream = new FileInputStream(cpuInfo); bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 512); String line = bufferedReader.readLine(); if (line != null && line.length() > 0 && line.toLowerCase(Locale.US).contains("arch64")) { if (LOGENABLE) { // Log.d("###############isCPUInfo64()", PROC_CPU_INFO_PATH + " contains is arch64"); } return true; } else { if (LOGENABLE) { // Log.d("###############isCPUInfo64()", PROC_CPU_INFO_PATH + " is not arch64"); } } } catch (Throwable t) { if (LOGENABLE) { // Log.d("###############isCPUInfo64()","read " + PROC_CPU_INFO_PATH + " error = " + t.toString()); } } finally { try { if (bufferedReader != null) { bufferedReader.close(); } } catch (Exception e) { e.printStackTrace(); } try { if (inputStream != null) { inputStream.close(); } } catch (Exception e) { e.printStackTrace(); } } } return false; }
From source file:Main.java
/** * Whether the given URL is one of the expected URLs used in the bootstrapping process * of the app. Used for determining the app's "home page" URL. * @param url The URL to compare against the reserved list. * @return True if this URL is used in the bootstrapping process, false otherwise. *//*from w w w . j av a2s . c o m*/ private static boolean isReservedUrl(String url) { if (url == null || url.trim().equals("")) return false; for (String reservedUrlPattern : RESERVED_URL_PATTERNS) { if (url.toLowerCase(Locale.US).contains(reservedUrlPattern.toLowerCase(Locale.US))) return true; } return false; }
From source file:net.sf.util.zip.FileNameUtil.java
/** * * @param name the filename/* ww w . jav a 2 s . c o m*/ * @return the file extension or empty string if there is no extension */ public static String getExtension(String name) { final String lower = name.toLowerCase(Locale.ENGLISH); String ext = null; try { ext = lower.substring(lower.lastIndexOf("."), lower.length()); } catch (Throwable t) { ext = ""; } return ext; }