ATOMIC_MOVE gives exceptions

file, java, nio

Solution

As API says, `ATOMIC_MOVE` is not supported for `copy()`, but for `move()` only.

Problem

I am in the middle of automating a series of actions that we do a lot in order to gain some time. This involves moving files around and starting some batches. In this particular situation, I am trying to copy a file from one location to another location. All works fine, until I try to use the `ATOMIC_MOVE` copy option. This is my code: ``` private void copyToDropFolder(Datafile datafile, String company) throws IOException{ Path datafilePath = datafile.getDataPath(); String dropFolder = locations.getLocationFor("default"); Path dropPath = Paths.get(dropFolder, company.toUpperCase(),locations.getLocationFor("drop"), datafile.getFileName()); Files.copy(datafilePath, dropPath, StandardCopyOption.ATOMIC_MOVE); } ``` I have checked and resolved the locations of datafilePath and dropPath, they are both valid. I have tried with the other 2 standard copy options, and the program runs fine. It is only for `ATOMIC_MOVE` that I get an `UnsupportedOperationException`. It is not that I absolutely need that specific option, but I am curious why I wouldn't work. I cant really find any other reports on this issue. I am doing this on a Windows 7 machine. Am I missing something? Or is the `ATOMIC_MOVE` just not supported?

Original source