Skip to content

Instantly share code, notes, and snippets.

@coding4food
Created September 28, 2011 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coding4food/1248505 to your computer and use it in GitHub Desktop.
Save coding4food/1248505 to your computer and use it in GitHub Desktop.
Simple Java/Clojure comparison
(defn blank? [s]
(every? #(Character/isWhitespace %) s))
(import '(System))
(defn blank? [s]
(every? #(Char/IsWhiteSpace %) s))
public class StringUtils {
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment