@@ -155,20 +155,20 @@ public static Boolean copyFile2File(File srcFile, File dstFile) {
155
155
return true ;
156
156
}
157
157
158
- public static boolean deleteDirectory (String dirPath ) {
159
- File directoryToBeDeleted = new File ( dirPath );
158
+ public static boolean deleteDirectory (Path dirPath ) {
159
+ File directoryToBeDeleted = dirPath . toFile ( );
160
160
File [] allContents = directoryToBeDeleted .listFiles ();
161
161
if (allContents != null ) {
162
162
for (File file : allContents ) {
163
- deleteDirectory (file .getAbsolutePath ());
163
+ deleteDirectory (file .toPath ());
164
164
}
165
165
}
166
166
return directoryToBeDeleted .delete ();
167
167
}
168
168
169
- public static void copyDirectory (String srcDirStr , String destDirStr ) {
170
- File source = new File ( srcDirStr );
171
- File dest = new File ( destDirStr );
169
+ public static void copyDirectory (Path srcDirPath , Path destDirPath ) {
170
+ File source = srcDirPath . toFile ( );
171
+ File dest = destDirPath . toFile ( );
172
172
try {
173
173
FileUtils .copyDirectory (source , dest );
174
174
} catch (IOException e ) {
@@ -263,7 +263,7 @@ public static List<String> readFileToLineList(String filePath) {
263
263
public static void createFolder (String dirStr , Boolean deleteIfExist ) {
264
264
File dir = new File (dirStr );
265
265
if (deleteIfExist && dir .exists ()) {
266
- deleteDirectory (dir .getAbsolutePath ());
266
+ deleteDirectory (dir .toPath ());
267
267
dir .mkdirs ();
268
268
} else if (!dir .exists ()) {
269
269
dir .mkdirs ();
@@ -280,11 +280,11 @@ public static boolean deleteDirectory(File directoryToBeDeleted) {
280
280
return directoryToBeDeleted .delete ();
281
281
}
282
282
283
- public static List <File > findFilePathofSpecifcTypeRecusive (String tarDir , String extension ) {
283
+ public static List <File > findFilePathofSpecifcTypeRecusive (Path tarDir , String extension ) {
284
284
285
285
List <File > fileList = new ArrayList <File >();
286
286
try {
287
- Files .walk (Paths . get ( tarDir ) ).filter (Files ::isRegularFile ).forEach ((f ) -> {
287
+ Files .walk (tarDir ).filter (Files ::isRegularFile ).forEach ((f ) -> {
288
288
String filepath = f .toString ();
289
289
if (filepath .endsWith (extension ))
290
290
// System.out.println(file + " found!");
0 commit comments