List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:Main.java
public static <T> T fromJson(String jsonInString, Class<T> responseType) { try {//ww w . j a va 2 s.c o m if (jsonInString == null || !jsonInString.isEmpty()) { return (T) gson.fromJson(jsonInString, responseType); } return null; } catch (Exception ex) { return null; } }
From source file:onl.area51.httpd.util.ContentTypeResolver.java
public static ContentType resolve(String path) { if (path != null && !path.isEmpty()) { int i = path.lastIndexOf('.'); int j = path.lastIndexOf('/'); if (i > -1 && i > j) { return CONTENT_TYPES.getOrDefault(path.substring(i).toLowerCase(), APPLICATION_OCTET_STREAM); }/*from w ww . ja v a 2s. co m*/ } return ContentType.APPLICATION_OCTET_STREAM; }
From source file:Main.java
public static int getKlassenstufe(String klassenname) throws NumberFormatException { if (klassenname.isEmpty()) { return 0; }//from w ww. ja va 2 s .co m String klassenstufe = klassenname.substring(0, 1); if (keineKlassenstufeEnthalten(klassenstufe)) { return 0; } if (klassenname.length() > 1) { if (Integer.valueOf(klassenstufe) == 1) { if (klassenname.substring(1, 2).equals("0")) { return Integer.valueOf(klassenname.substring(0, 2)); } } } return Integer.valueOf(klassenstufe); }
From source file:Main.java
@SuppressLint("NewApi") public static boolean isGetListSuccess(String listjson) { if (listjson == null) { return false; }//from w ww . j a v a 2 s . c om if (listjson.isEmpty()) { return false; } if (listjson.contains("error_code")) { return false; } else { return true; } }
From source file:Main.java
/** * Returns the IMEI Number./*from w w w .ja v a 2s . c o m*/ * @return - Device IMEI number. */ public static String getDeviceId(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = telephonyManager.getDeviceId(); if (deviceId == null || deviceId.isEmpty()) { deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } return deviceId; }
From source file:Main.java
/** * @param filePath filePath example("pictures") *//*from w w w. ja va 2 s.c om*/ public static List<String> traversalAssetsFiles(Context context, String filePath) { List<String> files = new ArrayList<>(); try { for (String file : context.getAssets().list(filePath)) { if (file != null && !file.isEmpty()) { if (file.endsWith(".jpg") || file.endsWith(".gif") || file.endsWith(".png")) { files.add(file); } } } } catch (IOException e) { e.printStackTrace(); } return files; }
From source file:Main.java
private static int[] longestSubstring(String str1, String str2) { if (str1 == null || str1.isEmpty() || str2 == null || str2.isEmpty()) return null; // dynamic programming => save already identical length into array // to understand this algo simply print identical length in every entry of the array // i+1, j+1 then reuses information from i,j // java initializes them already with 0 int[][] num = new int[str1.length()][str2.length()]; int maxlen = 0; int lastSubstrBegin = 0; int endIndex = 0; for (int i = 0; i < str1.length(); i++) { for (int j = 0; j < str2.length(); j++) { if (str1.charAt(i) == str2.charAt(j)) { if ((i == 0) || (j == 0)) num[i][j] = 1;/* ww w. j ava 2 s. co m*/ else num[i][j] = 1 + num[i - 1][j - 1]; if (num[i][j] > maxlen) { maxlen = num[i][j]; // generate substring from str1 => i lastSubstrBegin = i - num[i][j] + 1; endIndex = i + 1; } } } } return new int[] { lastSubstrBegin, endIndex }; }
From source file:Main.java
/** * Returns the {@code Class} object associated with the given {@link Type} * depending on its fully qualified name. * * @param type the {@code Type} whose {@code Class} is needed. * @return the {@code Class} object for the class with the specified name. * * @throws ClassNotFoundException if the class cannot be located. * * @see {@link ReflectionUtils#getClassName(Type)} *//* w w w . j a v a2 s. co m*/ public static Class<?> getClass(Type type) throws ClassNotFoundException { String className = getClassName(type); if (className == null || className.isEmpty()) { return null; } return Class.forName(className); }
From source file:Main.java
public static String domainToAscii(String input) { try {// www . j a v a 2s.c o m String result = IDN.toASCII(input).toLowerCase(Locale.US); if (result.isEmpty()) return null; if (containsInvalidHostnameAsciiCodes(result)) { return null; } return result; } catch (IllegalArgumentException e) { return null; } }
From source file:Main.java
public static String cloneString(final String toClone) { if (toClone == null) { return null; }//from w ww.j av a2s. com if (toClone.isEmpty()) { return new String("").concat(new String("")); } if (toClone.length() == 1) { return String.valueOf(toClone.charAt(0)); } return toClone.substring(0, 1) + toClone.substring(1); }