How to copy file in Java from one directory to another is common requirement, given that there is no direct method in File API for copying files from one location to another. Painful way of copying file is reading from FileInputStream and writing same data to FileOutputStream to another directory. Though this process works its pretty raw to work with and best approach is for anyone to create library for common File operation like cut, copy, paste etc. Thankfully you don't need to reinvent wheel here, there are some open source library available which allows us to copy file in Java easily from one directory to another. One of such library is Apache commons IO which contains a class called FileUtils, which provides utility method for file related operation. FileUtils.copyFile(sourceFile, targetFile) can be used to copy files in Java. This Java program copy file from one location to other using FileUtils class.
This Java programming tutorial is next in series of earlier article in File API like how to create hidden file in Java and how to read from text file. If you are new to Java File API you may find them useful.