public class FileCopy {
Public static void main (String [] args) {
Try {
CopyDir (" aa "D: \ \, D: \ " bb ");
} the catch (IOException e) {
e.printStackTrace();
}
}
Public static void copyDir (String sourcePath, String newPath) throws IOException {
The File File=new File (sourcePath);
FilePath String []=file. The list ();
if (! (new File (newPath)). The exists ()) {
(new File (newPath)). The mkdir ();
}
for (int i=0; i
If ((new File (sourcePath + File. The separator + filePath [I])). The isDirectory ()) {
CopyDir (sourcePath + file. The separator + filePath [I], newPath + file. The separator + filePath [I]);
}
If (new File (sourcePath + File. The separator + filePath [I]). IsFile ()) {
Used by copyFile (sourcePath + file. The separator + filePath [I], newPath + file. The separator + filePath [I]);
}
}
}
Public static void used by copyFile (String oldPath, String newPath) throws IOException {
The File oldFile=new File (oldPath);
The File File=new File (newPath);
FileInputStream in=new FileInputStream (oldFile);
FileOutputStream out=new FileOutputStream (file);
Byte [] buffer=new byte [2097152].
While ((in the read (buffer))!=1) {
Out. Write (buffer);
}
out.close();
in.close();
}
}
CodePudding user response:
Why no one to helpCodePudding user response:
How are you? Can I put this code into a smaliCodePudding user response:
Did anyone give me some help