通用脫敏工具類和判斷URL

2021-10-21 17:26:14 字數 1357 閱讀 5448

通用脫敏工具類

public

class

desensitizationutil

int len = value.

length()

;int pamaone = len /2;

int pamatwo = pamaone -1;

int pamathree = len %2;

stringbuilder stringbuilder =

newstringbuilder()

;if(len <=2)

stringbuilder.

(symbol)

; stringbuilder.

(value.

charat

(len -1)

);}else

else

if(pamatwo >= size /

2&& size +

1!= len)if(

(pamathree ==

0&& size /2==

0)||(pamathree !=

0&& size %2!=

0))else

}else

stringbuilder.

(value.

substring

(len -

1, len));

}}return stringbuilder.

tostring()

;}}

判斷url

public

class

isurlutil

[pp]:/*|[hh][tt][pp][ss]:/*|[ff][tt][pp]:/*)(([a-za-z0-9-~]+).)+([a-za-z0-9-~\\/])+(\\?(([a-za-z0-9-~]+\\=)([a-za-z0-9-~]*)\\&)*)$"

;// 編譯正規表示式

pattern pattern =

pattern

.compile

(regex)

;// 忽略大小寫的寫法

// pattern pat = pattern.compile(regex, pattern.case_insensitive);

matcher matcher = pattern.

matcher

(url)

;// 字串是否與正規表示式相匹配

boolean rs = matcher.

matches()

;return rs;

}}

**皆為網上蒐集而來,侵權聯刪。。。

脫敏工具類

呼叫方法 保單號後六位顯示為 string policyno 123213412414 policyno desensitizationutil.idpassport policyno 6 脫敏工具類 package com.ssish.wxmall.common.data import org.a...

網路判斷工具類

package org.easycoding.mobile.android.utils import android.content.context import android.net.connectivitymanager import android.net.networkinfo publi...

雙擊判斷工具類和EditText彈出軟鍵盤監聽

雙擊判斷工具類 public class doubleclickhelper 判斷是否在time時間內進行了雙擊操作,time的單位是毫秒 public static boolean isondoubleclick int time edittext彈出軟鍵盤監聽 public class soft...