[JAVA] String null 값 확인 StringUtils 사용

Glen(OH TaekJoo)·2023년 12월 12일
0

Study

목록 보기
51/53
if(text==null){}

위처럼 작성할 시 null 값만 허용.
"" 처럼 빈값은 false 로 인식한다.

StringUtils.isEmpty(text)

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

isEmpty 사용시 null과 빈값도 true 로 인식한다.

StringUtils.isBlank(text)

inBlank 사용시 null 과 빈값 , 공백 까지 true 로 인식한다.

StringUtils 를 이용하여 예외처리를 줄일 수 있다

profile
병아리 개발자 의 우당탕탕 성장기

0개의 댓글