List of usage examples for java.lang String length
public int length()
From source file:Main.java
private static String getUnclosedTagWithSubstring(String text) { if (text.length() == 0) { return ""; } else if (text.matches("^.*(<[a-zA-Z]*>)$")) { return text; } else if (text.matches("^.*(</[a-zA-Z]*>)$")) { return ""; } else {/*from w w w .j a v a 2s. c om*/ return getUnclosedTagWithSubstring(text.substring(0, text.length() - 1)); } }
From source file:Main.java
public static String crop(String value, int howMuch) { return (value.length() <= howMuch) ? value : (value.substring(0, howMuch - 3) + "..."); }
From source file:Main.java
/** * Tests if the given string <i>might</i> already be a 32-char md5 string. * //from ww w . ja va 2 s . com * @param s String to test * @return <code>true</code> if the given String might be a md5 string */ public static boolean isMD5(final String s) { return s.length() == 32 && MD5_PATTERN.matcher(s).matches(); }
From source file:Main.java
@SuppressWarnings("unchecked") public static Class resolvePrimitiveClassName(String name) { if (name.length() <= 8) { for (int i = 0; i < PRIMITIVE_CLASSES.length; i++) { Class clazz = PRIMITIVE_CLASSES[i]; if (clazz.getName().equals(name)) return clazz; }//from w w w . jav a 2 s. c o m } return null; }
From source file:Main.java
/** * Writes long strings to the logcat.//from w ww .j a v a 2 s . c o m * * @param str The string to write to the logcat. */ public static void logLongStrings(String logTag, String str) { if (str.length() > 4000) { Log.d(logTag, str.substring(0, 4000)); logLongStrings(logTag, str.substring(4000)); } else { Log.d(logTag, str); } }
From source file:Main.java
public static boolean isValidBillNum(String str) { return str != null && str.length() >= 8 && str.length() <= 32; }
From source file:Main.java
public static boolean isNumeric(String str) { for (int i = str.length(); --i >= 0;) { if (!Character.isDigit(str.charAt(i))) { return false; }/* w ww . jav a 2 s . c o m*/ } return true; }
From source file:Main.java
public static String toMacFormat(String mac) { if (mac.length() == 12) { StringBuffer sb = new StringBuffer(mac); sb.insert(10, ':'); sb.insert(8, ':'); sb.insert(6, ':'); sb.insert(4, ':'); sb.insert(2, ':'); return sb.toString(); }//from w w w . j a v a 2 s .co m return ""; }
From source file:Main.java
public static boolean checkLengthEq(Object strObj, int length) { String str = strObj + ""; return str.length() == length; }
From source file:Main.java
public static boolean isValidBillNum(String str) { return str != null && str.length() >= 8 && str.length() <= 32 && str.matches("[A-Za-z0-9]+"); }