|
|
@ -26,6 +26,7 @@ import java.util.function.Function;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
|
|
|
|
|
|
@ -203,10 +204,15 @@ public class CmmnUtil {
|
|
|
|
* @return 삭제된 폴더수
|
|
|
|
* @return 삭제된 폴더수
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static void removeDuplicateFileName(String root) {
|
|
|
|
public static void removeDuplicateFileName(String root) {
|
|
|
|
try {
|
|
|
|
List<Path> fileList = null;
|
|
|
|
|
|
|
|
try (Stream<Path> pathStream = Files.walk(Paths.get(root))){
|
|
|
|
|
|
|
|
|
|
|
|
List<Path> fileList = Files.walk(Paths.get(root)).filter(Files::isRegularFile).toList();
|
|
|
|
fileList = pathStream.filter(Files::isRegularFile).toList();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(fileList != null && !fileList.isEmpty()) {
|
|
|
|
Map<String, List<Path>> byFileName = fileList.stream().collect(Collectors.groupingBy(item -> item.toFile().getName()));
|
|
|
|
Map<String, List<Path>> byFileName = fileList.stream().collect(Collectors.groupingBy(item -> item.toFile().getName()));
|
|
|
|
|
|
|
|
|
|
|
|
Iterator<String> keys = byFileName.keySet().iterator();
|
|
|
|
Iterator<String> keys = byFileName.keySet().iterator();
|
|
|
@ -224,15 +230,13 @@ public class CmmnUtil {
|
|
|
|
|
|
|
|
|
|
|
|
for(Path sameNameFile : sameNameFileList) {
|
|
|
|
for(Path sameNameFile : sameNameFileList) {
|
|
|
|
if(!sameNameFile.equals(latest)) {
|
|
|
|
if(!sameNameFile.equals(latest)) {
|
|
|
|
sameNameFile.toFile().delete();
|
|
|
|
if(!sameNameFile.toFile().delete()) {
|
|
|
|
|
|
|
|
throw new RuntimeException("[F]파일 삭제 오류");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|