List of usage examples for java.lang String toLowerCase
public String toLowerCase()
From source file:Main.java
public static boolean matchesIgnoreCase(String text, String lowerCasePattern) { return (text.length() >= lowerCasePattern.length()) && (text.toLowerCase().indexOf(lowerCasePattern) >= 0); }
From source file:Main.java
/** * Returns the body part of the given HTML markup. */// w w w . ja v a 2s.c om public static String getBodyMarkup(String markup, boolean replaceLinefeeds) { String lowerCase = markup.toLowerCase(); int bodyStart = lowerCase.indexOf("<body>"); if (bodyStart >= 0) { bodyStart += 7; int bodyEnd = lowerCase.lastIndexOf("</body>"); if (bodyEnd > bodyStart) { markup = markup.substring(bodyStart, bodyEnd).trim(); } } if (replaceLinefeeds) { markup = markup.replaceAll("\n", "<br>"); } return markup; }
From source file:Main.java
private static String capitalizeAllWords(String str) { String phrase = ""; boolean capitalize = true; for (char c : str.toLowerCase().toCharArray()) { if (Character.isLetter(c) && capitalize) { phrase += Character.toUpperCase(c); capitalize = false;//from ww w . j a v a 2 s . c o m continue; } else if (c == ' ') { capitalize = true; } phrase += c; } return phrase; }
From source file:Main.java
public static String getEncoding(String f) { String encoding = "UTF-8"; File file = new File(f); try {/* w ww . jav a 2 s. c om*/ BufferedReader reader = new BufferedReader(new FileReader(file)); String xml = reader.readLine(); reader.close(); xml = xml.toLowerCase(); int pos = xml.indexOf("encoding"); if (pos < 0) { return encoding; } xml = xml.substring(pos + "encoding".length()); pos = xml.indexOf("\""); xml = xml.substring(pos + 1); pos = xml.indexOf("\""); xml = xml.substring(0, pos).trim(); return xml.toUpperCase(); } catch (Exception ex) { ex.printStackTrace(); } return encoding; }
From source file:Main.java
/** * Creates a FileFilter for a specified description * and an array of allowed extensions. <br /> * /*from www . j av a 2s . c om*/ * @param extensions the allowed extensions without a dot * @param description the displayed description * @return the created FileFilter */ public static FileFilter createFilter(final String[] extensions, final String description) { return new FileFilter() { @Override public boolean accept(File file) { if (file.isDirectory()) { return true; } String name = file.getName().toLowerCase(); for (String e : extensions) { if (name.endsWith("." + e.toLowerCase())) { return true; } } return false; } @Override public String getDescription() { return description; } }; }
From source file:com.gistlabs.mechanize.document.html.JsoupDataUtil.java
/** Returns the all elements matching any of the given tags (case-insensitive). */ public static Elements findElementsByTag(Element element, String... tags) { List<Element> results = new ArrayList<Element>(); Set<String> tagSet = new HashSet<String>(); for (String tag : tags) tagSet.add(tag.toLowerCase()); filterElementsByTag(results, element, tagSet); return new Elements(results); }
From source file:Main.java
public static boolean isEmpty(String input) { if (input == null || "".equals(input) || "null".equals(input.toLowerCase())) return true; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; }/*from w w w. jav a 2 s . c om*/ } return true; }
From source file:Main.java
protected static boolean checkFileSuffix(String filePath) { for (int i = 0; i < _permittedSuffix.length; i++) { String lowerCase = filePath.toLowerCase(); if (lowerCase.endsWith(_permittedSuffix[i])) { return true; }// w ww.j a v a 2 s. c o m } return false; }
From source file:Main.java
private static boolean isImageFormat(String fileName) { if (fileName == null) { return false; }/*from ww w. jav a2 s . co m*/ fileName = fileName.toLowerCase(); if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith(".png") || fileName.endsWith(".bmp") || fileName.endsWith(".jpe") || fileName.endsWith(".gif") || fileName.endsWith(".wbmp")) { return true; } return false; }
From source file:Main.java
public static boolean installApp(Context context, String filePath) { if (filePath != null && filePath.length() > 4 && filePath.toLowerCase().substring(filePath.length() - 4).equals(".apk")) { Intent intent = new Intent(Intent.ACTION_VIEW); File file = new File(filePath); if (file.exists() && file.isFile() && file.length() > 0) { intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return true; }//from w w w.j ava2 s. c om } return false; }