fix[storage]: fixed the issue that when packaged as a jar, the resource could not get the absolute path

This commit is contained in:
godotg
2022-12-13 11:10:42 +08:00
parent 80a04ae581
commit d95088cfa8
7 changed files with 100 additions and 150 deletions
@@ -15,10 +15,7 @@ package com.zfoo.protocol.util;
import com.zfoo.protocol.collection.ArrayUtils;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.regex.Pattern;
/**
@@ -99,32 +96,10 @@ public abstract class StringUtils {
*/
public static final String ENGLISH_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final Set<Character> ENGLISH_SET = Set.of(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
);
public static final Set<Character> ENGLISH_SET = Set.of('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
public static final Set<Character> STOP_WORD = Set.of(
' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '/', '[', '{', ']', '}'
, '\\', '|', ';', ':', '\'', '"', ',', '<', '.', '>', '?',
'·', '', '¥', '', '。', '、', 'ˇ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '_', '', '', '',
'—', '', '‖', '…', '', '', '“', '”', '〈', '〉', '《', '》', '「', '」', '『',
'』', '〖', '〗', '【', '】', '±', '', '', '×', '÷', '∧', '', '∏', '', '∩', '∈', '√', '⊥', '⊙', '∫',
'∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '', '∵', '∴', '∷', '♂', '♀', '°', '', '〃',
'℃', '', '¤', '¢', '£', '‰', '§', '☆', '★', '', '○', '●', '◎', '◇', '◆', '□', '■', '△', '▽', '⊿', '▲',
'▼', '◣', '◤', '◢', '◥', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▉', '▊', '▋', '▌', '▍', '▎', '▏', '▓',
'※', '→', '←', '↑', '↓', '↖', '↗', '↘', '↙', '〓',
'①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩',
'⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', '⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', '⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇',
'', 'Ⅱ', 'Ⅲ', 'Ⅳ', '', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', '', 'Ⅺ', 'Ⅻ',
'', 'ⅱ', 'ⅲ', 'ⅳ', '', 'ⅵ', 'ⅶ', 'ⅷ', 'ⅸ', '',
'', '', '', '', '', '', '', '', '', '',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'Ρ', '∑', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π',
'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', '', '﹊', '', '╭', '╮', '╰', '╯',
'々', '', '', '', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕',
'´', '');
public static final Set<Character> STOP_WORD = Set.of(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '/', '[', '{', ']', '}', '\\', '|', ';', ':', '\'', '"', ',', '<', '.', '>', '?', '·', '', '¥', '', '。', '、', 'ˇ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '_', '', '', '', '—', '', '‖', '…', '', '', '“', '”', '〈', '〉', '《', '》', '「', '」', '『', '』', '〖', '〗', '【', '】', '±', '', '', '×', '÷', '∧', '', '∏', '', '∩', '∈', '√', '⊥', '⊙', '∫', '∮', '≡', '≌', '≈', '∽', '∝', '≠', '≮', '≯', '≤', '≥', '∞', '', '∵', '∴', '∷', '♂', '♀', '°', '', '〃', '℃', '', '¤', '¢', '£', '‰', '§', '☆', '★', '', '○', '●', '◎', '◇', '◆', '□', '■', '△', '▽', '⊿', '▲', '▼', '◣', '◤', '◢', '◥', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▉', '▊', '▋', '▌', '▍', '▎', '▏', '▓', '※', '→', '←', '↑', '↓', '↖', '↗', '↘', '↙', '〓', '①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', '⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', '⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇', '', 'Ⅱ', 'Ⅲ', 'Ⅳ', '', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', '', 'Ⅺ', 'Ⅻ', '', 'ⅱ', 'ⅲ', 'ⅳ', '', 'ⅵ', 'ⅶ', 'ⅷ', 'ⅸ', '', '', '', '', '', '', '', '', '', '', '', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Ρ', '∑', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', '', '﹊', '', '╭', '╮', '╰', '╯', '々', '', '', '', '卐', '㎎', '㎏', '㎜', '㎝', '㎞', '㎡', '㏄', '㏎', '㏑', '㏒', '㏕', '´', '');
// Empty checks
@@ -428,6 +403,28 @@ public abstract class StringUtils {
return result.toString();
}
/**
* Tokenize the given String into a String array via a StringTokenizer.
*/
public static String[] tokenize(String str, String delimiters) {
if (isEmpty(str)) {
return EMPTY_ARRAY;
}
if (isEmpty(delimiters)) {
return new String[]{str};
}
var st = new StringTokenizer(str, delimiters);
var tokens = new ArrayList<String>();
while (st.hasMoreTokens()) {
var token = trim(st.nextToken());
if (isBlank(token)) {
continue;
}
tokens.add(token);
}
return ArrayUtils.listToArray(tokens, String.class);
}
/**
* 格式化字符串
* 此方法只是简单将占位符 {} 按照顺序替换为参数