I want to copy some selected files to a Destination folder using core java. I cannot use JDK 7. I am using JDK 1.6. Copying the entire source Folder to the destination Folder isn’t acceptable.
Example :
Folder T contains x number of .gif files. I have to copy (not move) y (out of x) number of .gif image files to a separate folder, say K.
I cannot copy all of T (i.e x files) to K.
How would I do that in JDK 1.6?
Use FileUtils.copyDirectory() from commons-io , specifying your source, destination, and a filter that indicates to only copy .gif files. The method’s documentation includes an example of copying all
.txtfiles from one directory to another, so it gets you about 95% of the way there.