import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) throws IOException {
List lines1 = Files.readAllLines(Paths.get("D:", "1.txt"));
List> nums1 = lines1.stream().map(e -> Arrays.asList(e.split(","))).collect(Collectors.toList());
List lines2 = Files.readAllLines(Paths.get("D:", "2.txt"));
List> nums2 = lines1.stream().map(e -> Arrays.asList(e.split(","))).collect(Collectors.toList());
List lines3 = new ArrayList<>();
for (int i = 0; i
for (int j = 0; j
if (nums1.get(i).containsAll(nums2.get(j))) {
lines3.add(lines1.get(i));
break;
}
}
}
Files.write(Paths.get("D:", "3.txt"), lines3);
}
}
其中路径的名字Paths.get("D:", "3.txt")中间可以有多个字符串,
比如Paths.get("D:","文件夹A","文件夹B", "3.txt")