Use Files.move instead of File.renameTo

This prevents problems when building PMD under Windows
This commit is contained in:
Andreas Dangel
2018-02-24 20:40:38 +01:00
parent bff93c53fb
commit 3c280b8ef2

View File

@ -14,6 +14,7 @@ import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
@ -152,10 +153,7 @@ public class DocumentFile implements Document, Closeable {
reader.close();
writer.close();
if (!temporaryPath.toFile().renameTo(filePath.toFile())) {
throw new IOException("Fixed file could not be renamed. Original path = " + filePath.toAbsolutePath());
}
temporaryPath.toFile().delete();
Files.move(temporaryPath, filePath, StandardCopyOption.REPLACE_EXISTING);
}
private void writeUntilEOF() throws IOException {