title: How to move (large) files between file systems in Java?
body: <p>In my Java 7 application I need to move all files and directories in the <code>sourceFolder</code> to another <code>destinationFolder</code>. I do not know whether these two folders are on the same file system or partition, as both can be specified by the user at runtime.</p>
  
  <p>Since the files and directories to move can be quite large (some GB), I was searching for an efficient way of moving them. So they should only be copied if <code>sourceFolder</code> and <code>destinationFolder</code> are not on the same file system. So ideally the move operation on the same file system should rather be a rename operation, if possible.</p>
  
  <p>The application is used on both Windows and Linux systems.</p>
  
  <p>I know about some <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html" rel="nofollow">related Java 7 functionalities</a>, however, they do not allow to move all contents of a folder to somewhere else if it is not empty, which is a requirement in my case. I also found <a href="http://commons.apache.org/proper/commons-io/javadocs/api-1.4/org/apache/commons/io/FileUtils.html" rel="nofollow">Apache Common's FileUtils</a> class, which looks promising. However, its documentation says one should do a <em>"copy and delete"</em> operation if <code>sourceFolder</code> and <code>destinationFolder</code> are not on the same file system.</p>
  
  <p>So my question is: When I use that <code>FileUtils</code> class, how can I then check the file systems of <code>sourceFolder</code> and <code>destinationFolder</code> in a cross-platform manner?</p>