空指针修正

This commit is contained in:
黎润豪 2025-04-01 11:46:07 +08:00
parent f9c9727fcf
commit 9016410765
1 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
@ -29,11 +30,14 @@ public class LocationHolidayDataManager extends AbstractHolidayDataManager {
@Override
public List<Holiday> flushData() {
String configPath = config.getConfigPath() != null ? config.getConfigPath().trim() : "classpath:holiday";
File dir;
File dir = new File(configPath);
if (configPath.startsWith("classpath:")) {
String path = configPath.substring("classpath:".length());
try {
dir = new File(this.getClass().getClassLoader().getResource(path).toURI());
URL resource = this.getClass().getClassLoader().getResource(path);
if (resource != null) {
dir = new File(resource.toURI());
}
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}