JDK-6878283 : (fs) Path.moveTo option that prevents the operation copying the file
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2009-09-02
  • Updated: 2018-09-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Currently the moveTo method provides for two simple usages:


  source.moveTo(target, REPLACE_EXISTING)

and one advanced usage:

  source.moveTo(target, ATOMIC_MOVE)

The simple usages are allowed to implement the move as a copy+delete so that they can move the file to another volume/file-system. The advanced case is required to be atomic but cannot provide a guarantee that it won't override an existing file.

This RFE is submitted to consider the case where an application wants to rename a file and have it fail if the target is on another volume/file-system -- ie: something like:

	source.moveTo(target, NOCOPY_ALLOWED)

WORK AROUND if (target.notExists()) source.moveTo(target, ATOMIC_MOVE);