Blame view

app/src/main/java/com/sunvote/xpadapp/utils/MyStringUtil.java 1.05 KB
27983dbe   孙向锦   project init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  package com.sunvote.xpadapp.utils;
  
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  /**
   * Created by lihuimin on 2017/7/26.
   */
  
  public class MyStringUtil {
  
      public static String replaceBlank(String str) {
          String dest = "";
          if (str != null) {
              Pattern p = Pattern.compile("\\s*|\t|\r|\n");
              Matcher m = p.matcher(str);
              dest = m.replaceAll("");
          }
          return dest;
      }
  
  
      /**
       * 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串,返回true
       * @param input
       * @return boolean
       */
      public static boolean isEmpty(String input) {
          if (input == null || "".equals(input) || input.isEmpty())
              return true;
          for (int i = 0; i < input.length(); i++) {
              char c = input.charAt(i);
              if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
                  return false;
              }
          }
          return true;
      }
  }