まにょのITメモ
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
■StringUtils isEmpty(String str)
public static boolean isEmpty(String str){
return str == null || str.length() == 0;
}
=================
チェック内容
・nullチェック
・空文字チェック
=================
■StringUtils isBlank(String str)
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))){
return false;
}
}
return true;
}
=================
チェック内容
・nullチェック
・空文字チェック
・全角半角スペースチェック
・その他スペース ※1
=================
※1
チェック対象のスペース一覧(ユニコード)
『\u0009』、『\u000A』、『\u000B』
『\u000C』、『\u000D』、『\u001C』
『\u001D』、『\u001E』、『\u001F』
内容は下記のURLを参照
www.tamasoft.co.jp/ja/general-info/unicode.html
public static boolean isEmpty(String str){
return str == null || str.length() == 0;
}
=================
チェック内容
・nullチェック
・空文字チェック
=================
■StringUtils isBlank(String str)
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))){
return false;
}
}
return true;
}
=================
チェック内容
・nullチェック
・空文字チェック
・全角半角スペースチェック
・その他スペース ※1
=================
※1
チェック対象のスペース一覧(ユニコード)
『\u0009』、『\u000A』、『\u000B』
『\u000C』、『\u000D』、『\u001C』
『\u001D』、『\u001E』、『\u001F』
内容は下記のURLを参照
www.tamasoft.co.jp/ja/general-info/unicode.html
PR
この記事にコメントする