Moving a file to a directory

This moves a file to directory.

File file = new File("file.txt");
File dir = new File("directory");
boolean fileMoved = file.renameTo(new File(dir, file.getName()));