package com.risen.oa.util;
import java.util.LinkedHashSet;
import java.util.Set;
public class StringHelper {
//移除相同字符
public static String removeSameString(String str) {
Set<String> mLinkedSet = new LinkedHashSet<String>();
String[] strArray = str.split(",");
StringBuffer sb = new StringBuffer();
for (int i = 0; i < strArray.length; i++) {
if (!mLinkedSet.contains(strArray[i])) {
mLinkedSet.add(strArray[i]);
sb.append(strArray[i] + ",");
}
}
if (sb.length() > 0) {
return sb.toString().substring(0, sb.toString().length() - 1);
} else {
return "";
}
}
//移除指定字符
public static String removeTargetString(String src,String reg) {
if (src.contains(",")) {
String[] srcs = src.split(",");
StringBuffer sb = new StringBuffer();
for (String name : srcs) {
if ("" != name) {
if (!name.equals(reg)) {
sb.append(name + ",");
}
}
}
if (sb.length() > 0) {
return sb.toString().substring(0, sb.toString().length() - 1);
} else {
return "";
}
} else {
return "";
}
}
}
//