Added support for base64Decode

This commit is contained in:
Shekhar Gulati
2016-05-16 18:17:41 +05:30
parent 47e20b35eb
commit 8fda832b80
2 changed files with 21 additions and 2 deletions
+13 -2
View File
@@ -1,6 +1,7 @@
package strman;
import java.util.Arrays;
import java.util.Base64;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.function.Predicate;
@@ -143,9 +144,9 @@ public abstract class Strman {
public static boolean contains(final String value, final String needle, final boolean caseSensitive) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (caseSensitive) {
return value.indexOf(needle) > -1;
return value.contains(needle);
}
return value.toLowerCase().indexOf(needle.toLowerCase()) > -1;
return value.toLowerCase().contains(needle.toLowerCase());
}
/**
@@ -294,6 +295,16 @@ public abstract class Strman {
return _value.startsWith(_prefix) ? value : prefix + value;
}
/**
* Decodes data encoded with MIME base64
*
* @param value The data to decode
* @return decoded data
*/
public static String base64Decode(final String value) {
return new String(Base64.getDecoder().decode(value));
}
private static long countSubstr(String value, String subStr, boolean allowOverlapping, long count) {
int position = value.indexOf(subStr);
if (position == -1) {