根据固定字符串生成固定长度的有序字符串组合集,这里是根据固定长度字符串(如:8位长度),生成至少3位长度的有序字符串组合集合,下面看实例:
import java.util.HashSet;
import java.util.Set;
/**
* @author
* @Description:根据固定字符串生成固定长度的有序字符串组合集
* @date 2019年01月15日 12:08
*/
public class StringCutMethod {
public static String cutString(String plateNo) {
plateNo = plateNo.toUpperCase();
if (null == plateNo || plateNo.isEmpty()) {
return null;
}
//自定义去掉第一个字符,剩下的字符串进行有序组合
String secondString = plateNo.substring(1);
int len = secondString.length();
Set<String> set = new HashSet<>();
// 3个字符
for (int i = 0; i <= len - 3; i++) {
set.add(secondString.substring(i, i + 3));
}
// 4个字符
for (int i = 0; i <= len - 4; i++) {
set.add(