/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.core.test;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.assertj.core.util.Files;

import com.google.common.collect.Sets;

/**
 * @author 田平 create 2020年4月2日下午5:01:30
 *
 */
public class CompareFiles {

	public static void main(String[] args) {
		String dir1 = "F:\\workspace-micro-service\\micro-service\\micro-core\\target\\micro-core-1.0.0-SNAPSHOT-exec\\BOOT-INF\\lib";
		Set<String> names1 = getFileNames(dir1);
		
		String dir2 = "F:\\workspace-micro-service\\micro-service\\services\\service-sysmgr\\target\\service-sysmgr-1.0.0-SNAPSHOT-exec\\BOOT-INF\\lib";
		Set<String> names2 = getFileNames(dir2);

	
		Sets.difference(names2, names1).forEach(System.out::println);
	}

	public static Set<String> getFileNames(String dir) {
		List<String> files = Files.fileNamesIn(dir, false);
		Set<String> names = files.stream().map(name -> {
			int index = name.lastIndexOf("\\");
			return name.substring(index + 1);
		}).collect(Collectors.toSet());
		return names;
	}
}
