file

Neat way to move a file in Java without nio

Saw this somewhere and figured I would post it before I lost it. Here is a very easy and simply way to move a file in Java without using the new-ish nio APIs. File srcFile = new File(…some file to move…); File destFile = new File(…where to move the file…); srcFile.renameTo(destFile); That’s it. Pretty simple. In fact it is actually shorter than the nio way of doing things FileChannel in = new FileInputStream(source).