- public static String emptyNotPrintChar(String str){
- if(StringUtils.isEmpty(str)){
- return "";
- }
- byte [] bts =str.getBytes();
- int btsLength= bts.length;
- byte [] newBytes = new byte[btsLength];
- for (int i =0;i<btsLength;i++) {
- byte b =bts[i];
- if((b >=0 && b <=31) || b ==127){
- b =32;
- }
- newBytes[i]=b;
- }
- return new String(newBytes);
- }
- //该片段来自于http://www.codesnippet.cn/detail/100620149755.html
来源: http://www.codesnippet.cn/detail/100620149755.html