fix: 导入用户自定义配置文件
This commit is contained in:
parent
a391ed05e0
commit
877976f1d7
@ -21,9 +21,22 @@ import java.util.Objects;
|
||||
public class ShortcutKey implements ShortcutKeyInterface {
|
||||
@Override
|
||||
public void createShortcutKeyByConfig() {
|
||||
|
||||
String rootPath =System.getProperty("user.dir");
|
||||
// 构建JSON文件路径
|
||||
String jsonFilePath = rootPath +"/config/shortcutKey.json";
|
||||
InputStream inputStream = getClass().getResourceAsStream("/config/shortcutKey.json");
|
||||
StringBuffer jsonData = new StringBuffer();
|
||||
File file = new File(jsonFilePath);
|
||||
if(file.exists()){
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
jsonData.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@ -32,6 +45,8 @@ public class ShortcutKey implements ShortcutKeyInterface {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 转json对象
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
Gson gson = gsonBuilder.create();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user