Skip to content

Commit

Permalink
optimize: file-generate插件,换行符优化。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed May 29, 2024
1 parent 9e75e7e commit a408dd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void execute() throws MojoExecutionException {
} else {
// 新增文件
try {
fileInfo.setContent(fileInfo.getContent().replaceAll("\r?\n", "\r\n"));
if (!fileInfo.getContent().endsWith("\n")) {
fileInfo.setContent(fileInfo.getContent() + "\r\n");
}

IOUtils.createFile(file, fileInfo.getContent());
getLog().info("Generate file: " + fileInfo.getPath());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static void createFile(File newFile, String text) throws IOException {
}

try (FileOutputStream out = new FileOutputStream(newFile)) {
out.write(text.replaceAll("\r", "").getBytes());
out.write(text.getBytes());
out.flush();
}
}
Expand Down

0 comments on commit a408dd5

Please sign in to comment.