CacheManager.java 文件源码

java
阅读 42 收藏 0 点赞 0 评论 0

项目:powsybl-core 作者:
public Path create() {
    try {
        if (Files.exists(path)) {
            List<String> otherKeys;
            try (Stream<String> stream = Files.lines(getMetadataFile(), StandardCharsets.UTF_8)) {
                otherKeys = stream.collect(Collectors.toList());
            }
            if (!keys.equals(otherKeys)) {
                throw new PowsyblException("Inconsistent cache hash code");
            }
        } else {
            Files.createDirectories(path);
            try (BufferedWriter writer = Files.newBufferedWriter(getMetadataFile(), StandardCharsets.UTF_8)) {
                for (String key : keys) {
                    writer.write(key);
                    writer.newLine();
                }
            }
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return path;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号