You are here:

Java/Automatically copy a file in Java


Is it possible to find a file in Java and then automatically make a copy (duplicate) of that file. For example, one class is created to find the desired file and then another class is created to automatically make a copy of that file.

If you know the name of the file and the directory it is in, you can use listFiles() to get a list of all files, and isDirectory() to determine if it is a directory you want to traverse.

If it put a file somewhere on the file system, you might have some issues.

If you want to copy a file see the Files class.


All Answers

Answers by Expert:

Ask Experts


Artemus Harper


I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.


I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Washington State University

MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 All rights reserved.