LoginSignup
84
65

More than 1 year has passed since last update.

【Java】StringUtilsのisBlankとisEmptyの違い

Last updated at Posted at 2015-07-03

isEmptyはnullと空文字列をチェックする

StringUtils.isEmpty(null)      => true
StringUtils.isEmpty("")        => true
StringUtils.isEmpty(" ")       => false !
StringUtils.isEmpty("bob")     => false
StringUtils.isEmpty("  bob  ") => false

isBlankは空白文字もチェックされtrueになる

StringUtils.isBlank(null)      => true
StringUtils.isBlank("")        => true
StringUtils.isBlank(" ")       => true !
StringUtils.isBlank("bob")     => false
StringUtils.isBlank("  bob  ") => false

##ドキュメント
https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html

84
65
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
84
65