This repository was archived by the owner on Dec 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
src/main/java/id.my.alvinq.prokitid.libs Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 55import java .nio .file .attribute .BasicFileAttributes ;
66
77public class FileUtils {
8+
89 public static void copyFile (String from , String to ) {
910 try {
1011 Files .copy (Paths .get (from ), Paths .get (to ), StandardCopyOption .REPLACE_EXISTING );
11- } catch (IOException error ) {
12- }
12+ } catch (IOException error ) {}
13+ }
14+
15+ public static void copyFolder (String source , String target ) {
16+ try {
17+ final Path from = Paths .get (source );
18+ final Path to = Paths .get (target );
19+
20+ Files .walkFileTree (from , new SimpleFileVisitor <Path >() {
21+ @ Override
22+ public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs ) throws IOException {
23+ Path targetDir = to .resolve (from .relativize (dir ));
24+ if (!Files .exists (targetDir )) {
25+ Files .createDirectories (targetDir );
26+ }
27+ return FileVisitResult .CONTINUE ;
28+ }
29+
30+ @ Override
31+ public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
32+ Files .copy (file , to .resolve (from .relativize (file )), StandardCopyOption .REPLACE_EXISTING );
33+ return FileVisitResult .CONTINUE ;
34+ }
35+ });
36+ } catch (IOException error ) {}
1337 }
1438}
You can’t perform that action at this time.
0 commit comments