/**
* Writes the associated README to the specified {@link Path}.
*
* @param outputPath The {@link Path} to which the README should be written.
* @throws IOException
*/
protected void writeReadme(Path outputPath) throws IOException {
InputStream readmeResource = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(getClass().getSimpleName() + "_README.md");
Files.createDirectories(outputPath);
String username = System.getProperty("user.name");
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String date = formatter.format(now);
if (readmeResource != null) {
String readmeContent = new BufferedReader(new InputStreamReader(readmeResource)).lines()
.map(line -> {
if (line.contains("%DATE%") && line.contains("%USER%")) {
return line.replace("%DATE%", date).replace("%USER%", username);
}
return line;
})
.collect(Collectors.joining("\n"));
Files.write(outputPath.resolve("README.md"), readmeContent.getBytes());
}
}
WorkflowTask.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:mmm
作者:
评论列表
文章目录