File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
core/src/main/java/com/google/googlejavaformat/java Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 3434import java .io .PrintWriter ;
3535import java .io .Writer ;
3636import java .nio .charset .StandardCharsets ;
37+ import java .nio .file .Files ;
38+ import java .nio .file .StandardCopyOption ;
3739import java .util .ArrayList ;
3840import java .util .List ;
3941import java .util .concurrent .Callable ;
@@ -232,9 +234,19 @@ private boolean writeOutput(Write write) {
232234 }
233235 return false ;
234236 }
235- if (!new File (tempFileName ).renameTo (new File (fileToFormat .fileName ()))) {
237+ try {
238+ Files .move (
239+ new File (tempFileName ).toPath (),
240+ new File (fileToFormat .fileName ()).toPath (),
241+ StandardCopyOption .REPLACE_EXISTING );
242+ } catch (IOException e ) {
236243 synchronized (outputLock ) {
237- errWriter .append (tempFileName ).append (": cannot rename temp file" ).append ('\n' ).flush ();
244+ errWriter
245+ .append (tempFileName )
246+ .append (": cannot rename temp file: " )
247+ .append (e .getMessage ())
248+ .append ('\n' )
249+ .flush ();
238250 }
239251 return false ;
240252 }
You can’t perform that action at this time.
0 commit comments