Checking for a not null, not blank String in Java

前端 未结 8 1635
猫巷女王i
猫巷女王i 2021-01-31 13:24

I am trying to check if a Java String is not null, not empty and not whitespace.

In my mind, this code should have been quite up for the job.

         


        
8条回答
  •  一向
    一向 (楼主)
    2021-01-31 14:28

    You could take a look at JSR 303 Bean Validtion wich contains the Annotatinos @NotEmpty and @NotNull. Bean Validation is cool because you can seperate validation issues from the original intend of the method.

提交回复
热议问题