多个中继服务同步相关问题修改
parent
dce4804d8d
commit
7629c7bd00
@ -0,0 +1,37 @@
|
||||
package com.glxp.sale.admin.util;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class MyStrUtil {
|
||||
|
||||
public static String removeDuplicates(String S) {
|
||||
//ArrayDeque会比LinkedList在除了删除元素这一点外会快一点
|
||||
ArrayDeque<Character> deque = new ArrayDeque<>();
|
||||
char ch;
|
||||
for (int i = 0; i < S.length(); i++) {
|
||||
ch = S.charAt(i);
|
||||
//peek()方法用于返回此双端队列表示的队列的头元素,但不删除该元素。
|
||||
if (deque.isEmpty() || deque.peek() != ch) {
|
||||
deque.push(ch);
|
||||
} else {
|
||||
//pop()方法用于从此双端队列中弹出头元素,并删除该元素。
|
||||
deque.pop();
|
||||
}
|
||||
}
|
||||
String str = "";
|
||||
//剩余的元素即为不重复的元素
|
||||
while (!deque.isEmpty()) {
|
||||
str = deque.pop() + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
public static String deDup(String s) {
|
||||
return new LinkedHashSet<String>(Arrays.asList(s.split("/"))).toString().replaceAll("(^\\[|\\]$)", "").replace(", ", "/");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(deDup("http://192.168.6.3:9150/SP_SYNC_SERVER/SP_SYNC_SERVER/directToSpms/system/param/syncData/save"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue