Import Java.io.file;import java.io.fileinputstream;import java.io.fileoutputstream;import java.io.IOException; Import Java.io.inputstream;import Java.io.outputstream;public class Deepcopy {public static void main (string[] args) { Deepcopy ("F:/software/All Fonts", "F:/software/all_font");} Copy all Folder_source files (excluding folders) to dest_folder,private static void Deepcopy (String folder_source, String dest_folder) { File File1 = new file (Folder_source), if (File1.isfile ()) {copy (File1.getabsolutepath (), dest_folder+ "/" +file1.getname ());} else if (file1.isdirectory ()) {file[] Files2 = File1.listfiles (); for (int i = 0; i < files2.length; i++) {deepcopy (files2 [I].getabsolutepath (), Dest_folder);}}} public static Boolean copy (String Filefrom, String fileto) {try {inputstream in = new FileInputStream (filefrom); outputstre Am out = new FileOutputStream (fileto); byte[] bt = new Byte[1024];int Count;while ((count = In.read (BT)) > 0) {out.write (BT, 0, Count);} In.close (); Out.close (); System.out.println ("Copy finished!");return true;} catch (IOException ex) {ex.printstacktrace (); return false;}}}
A Java program that copies only files that do not copy folders