{"id":6865,"date":"2013-02-06T23:58:21","date_gmt":"2013-02-06T14:58:21","guid":{"rendered":"http:\/\/arison.jp\/blog\/?p=6865"},"modified":"2017-07-14T02:12:31","modified_gmt":"2017-07-13T17:12:31","slug":"java-stringutils-null-space-check","status":"publish","type":"post","link":"https:\/\/arison.jp\/blog\/2013\/02\/06\/java-stringutils-null-space-check\/","title":{"rendered":"\u3010Java\u3011null\u3084\u7a7a\u6587\u5b57\u3001\u7a7a\u767d\u6587\u5b57\u306e\u5165\u529b\u30c1\u30a7\u30c3\u30af"},"content":{"rendered":"<p><span class=\"font24px\">Apache Commons Lang\u306eStringUtils\u30af\u30e9\u30b9\u304c\u4fbf\u5229\u3002<br \/>\nnull\u3084\u7a7a\u6587\u5b57\u3001\u7a7a\u767d\u6587\u5b57\u306e\u5165\u529b\u30c1\u30a7\u30c3\u30af\u306b\u306fStringUtils\u3092\u5229\u7528\u3057\u3088\u3046\u3002<\/span><\/p>\n<p>\u3044\u3064\u3082\u3002isEmpty\u4f7f\u3046\u304bisBlank\u3067\u8ff7\u3046\u3002<br \/>\n\u5fc5\u9808\u5165\u529b\u9805\u76ee\u306a\u3089\u3001\u7a7a\u767d\u3092\u8a31\u53ef\u3059\u308b\u306a\u3089isEmpty\u3002<br \/>\n\u4e3b\u30ad\u30fc\u306e\u9805\u76ee\u306a\u3089\u3001\u7a7a\u767d\u6587\u5b57\u3092\u8a31\u53ef\u3057\u306a\u3044isBlank\u304c\u3044\u3044\u304b\u306a\u3002<\/p>\n<p><!--more--><\/p>\n<hr \/>\n<h3>isEmpty<\/h3>\n<p>public static boolean isEmpty(java.lang.String str)<br \/>\n<span class=\"font20px\">\u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304cNULL\u3001\u307e\u305f\u306f\u7a7a\u6587\u5b57\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/span><br \/>\n\u30d1\u30e9\u30e1\u30fc\u30bf: str \u2013 \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217<br \/>\n\u623b\u308a\u5024: \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304cNULL\u3001\u307e\u305f\u306f\u7a7a\u6587\u5b57\u306e\u5834\u5408\u306ftrue\u3001\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u306ffalse<\/p>\n<p>StringUtils.isEmpty(null)      \u306e\u5834\u5408 true<br \/>\nStringUtils.isEmpty(&#8220;&#8221;)        \u306e\u5834\u5408 true<br \/>\nStringUtils.isEmpty(&#8221; &#8220;)       \u306e\u5834\u5408 false<br \/>\nStringUtils.isEmpty(&#8220;\u3000&#8221;)      \u306e\u5834\u5408 false<br \/>\nStringUtils.isEmpty(&#8220;hoge&#8221;)    \u306e\u5834\u5408 false<\/p>\n<hr \/>\n<h3>isNotEmpty<\/h3>\n<p>public static boolean isNotEmpty(java.lang.String str)<br \/>\n<span class=\"font20px\">\u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304cNULL\u3067\u306a\u3044\u3001\u304b\u3064\u7a7a\u6587\u5b57\u3067\u306a\u3044\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/span><\/p>\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf: str \u2013 \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217<br \/>\n\u623b\u308a\u5024: \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304cNULL\u3067\u306a\u3044\u3001\u304b\u3064\u7a7a\u6587\u5b57\u3067\u306a\u3044\u5834\u5408\u306ftrue\u3001\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u306ffalse<\/p>\n<p>StringUtils.isNotEmpty(null)   \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotEmpty(&#8220;&#8221;)     \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotEmpty(&#8221; &#8220;)    \u306e\u5834\u5408 true<br \/>\nStringUtils.isNotEmpty(&#8220;\u3000&#8221;)   \u306e\u5834\u5408 true<br \/>\nStringUtils.isNotEmpty(&#8220;hoge&#8221;) \u306e\u5834\u5408 true<\/p>\n<hr \/>\n<h3>isBlank<\/h3>\n<p>public static boolean isBlank(java.lang.String str)<\/p>\n<p><span class=\"font20px\">\u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304c\u7a7a\u767d\u6587\u5b57\uff08\u6ce81\uff09\u3001\u307e\u305f\u306f\u7a7a\u6587\u5b57\u3001\u307e\u305f\u306fNULL\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/span><br \/>\n\u30d1\u30e9\u30e1\u30fc\u30bf: str \u2013 \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217<br \/>\n \u623b\u308a\u5024: \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304c\u7a7a\u767d\u6587\u5b57\u3001\u307e\u305f\u306f\u7a7a\u6587\u5b57\u3001\u307e\u305f\u306fNULL\u306e\u5834\u5408\u306ftrue\u3001\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u306ffalse<\/p>\n<p>StringUtils.isBlank(null)      \u306e\u5834\u5408 true<br \/>\nStringUtils.isBlank(&#8220;&#8221;)        \u306e\u5834\u5408 true<br \/>\nStringUtils.isBlank(&#8221; &#8220;)       \u306e\u5834\u5408 true<br \/>\nStringUtils.isBlank(&#8220;\u3000&#8221;)      \u306e\u5834\u5408 true<br \/>\nStringUtils.isBlank(&#8220;hoge&#8221;)    \u306e\u5834\u5408 false<\/p>\n<hr \/>\n<h3>isNotBlank<\/h3>\n<p>public static boolean isNotBlank(java.lang.String str)<\/p>\n<p><span class=\"font20px\">\u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304c\u7a7a\u767d\u6587\u5b57\uff08\u6ce81\uff09\u3067\u306a\u3044\u3001\u304b\u3064\u7a7a\u6587\u5b57\u3067\u306a\u3044\u3001\u304b\u3064NULL\u3067\u306a\u3044\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/span><br \/>\n\u30d1\u30e9\u30e1\u30fc\u30bf: str \u2013 \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217<br \/>\n\u623b\u308a\u5024: \u30c1\u30a7\u30c3\u30af\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u304c\u7a7a\u767d\u6587\u5b57\u3067\u306a\u3044\u3001\u304b\u3064\u7a7a\u6587\u5b57\u3067\u306a\u3044\u3001\u304b\u3064NULL\u3067\u306a\u3044\u5834\u5408\u306ftrue\u3001\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u306ffalse<\/p>\n<p>StringUtils.isNotBlank(null)   \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotBlank(&#8220;&#8221;)     \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotBlank(&#8221; &#8220;)    \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotBlank(&#8220;\u3000&#8221;)   \u306e\u5834\u5408 false<br \/>\nStringUtils.isNotBlank(&#8220;hoge&#8221;) \u306e\u5834\u5408 true<\/p>\n<hr \/>\n<p>\u6ce81\u3000\u7a7a\u767d\u6587\u5b57\u306fCharacter.isWhitespace\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u6587\u5b57\u5217\u306e\u3053\u3068\u3002<br \/>\n\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u3001\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u3092\u542b\u307f\u307e\u3059\u3002<\/p>\n<p>Character.isWhitespace(&#8216; &#8216;)      \u306e\u5834\u5408 true<br \/>\nCharacter.isWhitespace(&#8216;\u3000&#8217;)     \u306e\u5834\u5408 true<br \/>\nCharacter.isWhitespace(&#8216;\\r&#8217;)     \u306e\u5834\u5408 true  \u203bCARRIAGE RETURN<br \/>\nCharacter.isWhitespace(&#8216;\\n&#8217;)     \u306e\u5834\u5408 true  \u203bLINE FEED<br \/>\nCharacter.isWhitespace(&#8216;\\t&#8217;)     \u306e\u5834\u5408 true  \u203bHORIZONTAL TABULATION HT<br \/>\n\u3053\u3093\u306a\u66f8\u304d\u65b9\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\nCharacter.isWhitespace(&#8216;\\u0009&#8217;) \u306e\u5834\u5408 true  \u203b\u3044\u308f\u3086\u308b\\t HORIZONTAL TABULATION HT<br \/>\nCharacter.isWhitespace(&#8216;\\u000B&#8217;) \u306e\u5834\u5408 true  \u203bVERTICAL TABULATION<br \/>\nCharacter.isWhitespace(&#8216;\\u000C&#8217;) \u306e\u5834\u5408 true  \u203b\u3044\u308f\u3086\u308b\\f FORM FEED FF<br \/>\nCharacter.isWhitespace(&#8216;\\u001C&#8217;) \u306e\u5834\u5408 true  \u203bFILE SEPARATOR<br \/>\nCharacter.isWhitespace(&#8216;\\u001D&#8217;) \u306e\u5834\u5408 true  \u203bGROUP SEPARATOR<br \/>\nCharacter.isWhitespace(&#8216;\\u001E&#8217;) \u306e\u5834\u5408 true  \u203bRECORD SEPARATOR<br \/>\nCharacter.isWhitespace(&#8216;\\u001F&#8217;) \u306e\u5834\u5408 true  \u203bUNIT SEPARATOR<\/p>\n<hr \/>\n<h3>\u304a\u307e\u3051<\/h3>\n<p>Character.isWhitespace(&#8216;c&#8217;)      \u306e\u5834\u5408 false<br \/>\nCharacter.isWhitespace()         \u306e\u5834\u5408 \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\uff08\u5f15\u6570\u306a\u3057\uff09<br \/>\nCharacter.isWhitespace(&#8221;)       \u306e\u5834\u5408 \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\uff08\u6587\u5b57\u5b9a\u6570\u7121\u52b9\uff09<br \/>\nCharacter.isWhitespace(&#8216;hoge&#8217;)   \u306e\u5834\u5408 \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\uff08\u6587\u5b57\u5217\u3060\u3057\uff09<br \/>\nCharacter.isWhitespace(&#8216;\\b&#8217;)     \u306e\u5834\u5408 false \u203b\u3044\u308f\u3086\u308b\\b backspace BS<br \/>\nCharacter.isWhitespace(&#8216;\\u0008&#8217;) \u306e\u5834\u5408 false \u203b\u3044\u308f\u3086\u308b\\b backspace BS<br \/>\nCharacter.isWhitespace(&#8216; &#8216;\\u000A\\u000D)) \u2026CARRIAGE RETURN\u3068LINE FEED\uff08\u7b11\uff09\u203b\u3044\u308f\u3086\u308b\\r\\n<\/p>\n<p>CR LF\u306fisWhitespace\u3067\u6bd4\u8f03\u3067\u304d\u306a\u304b\u3063\u305f\u3002<\/p>\n<p>\u3010\u7a7a\u767d\u6587\u5b57\u306e\u53c2\u8003\u30b5\u30a4\u30c8\u3011<br \/>\nCharacter (Java Platform SE 6)<br \/>\nhttp:\/\/docs.oracle.com\/javase\/jp\/6\/api\/java\/lang\/Character.html#isWhitespace(char)<\/p>\n<hr \/>\n<p>\u6307\u5b9a\u3055\u308c\u305f\u6587\u5b57\u304c Java \u306e\u57fa\u6e96\u306b\u5f93\u3063\u305f\u7a7a\u767d\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u307e\u3059\u3002\u6b21\u306e\u57fa\u6e96\u306e\u3069\u308c\u304b\u3092\u6e80\u305f\u3059\u5834\u5408\u306b\u3060\u3051\u3001Java \u306e\u7a7a\u767d\u6587\u5b57\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u2022Unicode \u306e\u7a7a\u767d\u6587\u5b57 (SPACE_SEPARATOR\u3001LINE_SEPARATOR\u3001\u307e\u305f\u306f PARAGRAPH_SEPARATOR) \u3067\u3042\u308b\u304c\u3001\u975e\u533a\u5207\u308a\u30b9\u30da\u30fc\u30b9 (&#8216;\\u00A0&#8217;\u3001&#8217;\\u2007&#8217;\u3001&#8217;\\u202F&#8217;) \u3067\u306f\u306a\u3044<br \/>\n\u2022&#8217;\\u0009&#8217;\u3001HORIZONTAL TABULATION \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u000A&#8217;\u3001LINE FEED \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u000B&#8217;\u3001VERTICAL TABULATION \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u000C&#8217;\u3001FORM FEED \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u000D&#8217;\u3001CARRIAGE RETURN \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u001C&#8217;\u3001FILE SEPARATOR \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u001D&#8217;\u3001GROUP SEPARATOR \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u001E&#8217;\u3001RECORD SEPARATOR \u3067\u3042\u308b<br \/>\n\u2022&#8217;\\u001F&#8217;\u3001UNIT SEPARATOR \u3067\u3042\u308b<\/p>\n<hr \/>\n<p>\u3010\u53c2\u8003\u30b5\u30a4\u30c8\u3011<br \/>\nApache Commons Lang \u2013 StringUtils\uff08IsEmpty &#8211; IsBlank\uff09  TK Factory<br \/>\n<a href=\"http:\/\/tk-factory.net\/wordpress\/?p=1429\" title=\"Apache Commons Lang \u2013 StringUtils\uff08IsEmpty - IsBlank\uff09  TK Factory\">http:\/\/tk-factory.net\/wordpress\/?p=1429<\/a><\/p>\n<p>2009-04-22 &#8211; \u502d\u30de\u30f3\u65e5\u8a18\u3000Java \u3068 XML \u3068\u7a7a\u767d\u3068 (2) : \u6b63\u898f\u8868\u73fe<br \/>\n<a href=\"http:\/\/d.hatena.ne.jp\/waman\/20090422\" title=\"2009-04-22 - \u502d\u30de\u30f3\u65e5\u8a18\u3000Java \u3068 XML \u3068\u7a7a\u767d\u3068 (2) : \u6b63\u898f\u8868\u73fe\">http:\/\/d.hatena.ne.jp\/waman\/20090422<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Commons Lang\u306eStringUtils\u30af\u30e9\u30b9\u304c\u4fbf\u5229\u3002 null\u3084\u7a7a\u6587\u5b57\u3001\u7a7a\u767d\u6587\u5b57\u306e\u5165\u529b\u30c1\u30a7\u30c3\u30af\u306b\u306fStringUtils\u3092\u5229\u7528\u3057\u3088\u3046\u3002 \u3044\u3064\u3082\u3002isEmpty\u4f7f\u3046\u304bisBlank\u3067\u8ff7\u3046\u3002 \u5fc5\u9808\u5165\u529b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":17178,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4],"tags":[703,119],"class_list":["post-6865","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-diary","tag-java","tag-coding"],"_links":{"self":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts\/6865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/comments?post=6865"}],"version-history":[{"count":0,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts\/6865\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/media\/17178"}],"wp:attachment":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/media?parent=6865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/categories?post=6865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/tags?post=6865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}