Java 重复行(数据)检入多个文件

Java 重复行(数据)检入多个文件,java,groovy,jmeter,performance-testing,Java,Groovy,Jmeter,Performance Testing,我已经从Jmeter响应数据创建了多个具有重复序列号的文件 Duplicate.txt Duplicate1.txt Duplicate2.txt Etc..... C5FV55WGJ1 C5FV55WGJ1 C5FX1N2572 C5FX1N2578 C5G0F54VP3 C5G0F54VP9 C5G77R09C4 C5G77R0910 C5G7L33Y25 C5G7L33Y11 C5G7X7NWY6 C

我已经从Jmeter响应数据创建了多个具有重复序列号的文件

Duplicate.txt    Duplicate1.txt      Duplicate2.txt Etc.....

C5FV55WGJ1       C5FV55WGJ1
C5FX1N2572       C5FX1N2578
C5G0F54VP3       C5G0F54VP9
C5G77R09C4       C5G77R0910
C5G7L33Y25       C5G7L33Y11
C5G7X7NWY6       C5G7X7NW12
C5FX1N2577       C5FX1N2513

像上面的txt数据文件一样,我在一个目录中有多个文件。现在我想比较所有的.txt文件和每个.txt文件

如果duplicate找到任何序列号.txt文件,则希望在Jmeter Groovy Jmeter后处理器中创建一个带有序列号和.txt文件的双重重复的.txt文件

经验


你们能帮我解决这个问题吗。提前谢谢

Stackoverflow不是一种代码编写服务。如果您希望有人为您实现代码,您应该询问您的同事或聘请其他人

在这里,您应该提供自己的解决方案,该解决方案可能因某种原因无法正常工作,也可能无法按预期工作,并请求帮助,而不是端到端实现

作为例外,您可以使用以下代码段:

new File('/path/to/folder/with/your/duplicate/files').listFiles().each { file ->
    List<String> lines = file.readLines()
    new File('/path/to/folder/with/your/duplicate/files').listFiles(new FilenameFilter() {
        @Override
        boolean accept(File dir, String name) {
            return !file.getName().equals(name)
        }
    }).each { otherfile ->
        List<String> otherLines = otherfile.readLines()
        lines.each { line ->
            if (otherLines.contains(line)) {
                new File('Double Duplicate.txt') << line << ' ('<< file.getName() << ' & ' << otherfile.getName() << ')' << System.getProperty('line.separator')
            }
        }
    }
}
新文件('/path/to/folder/with/your/duplicate/files').listFiles()。每个{File->
列表行=file.readLines()
新文件('/path/to/folder/with/your/duplicate/files').listFiles(新文件名过滤器(){
@凌驾
布尔接受(文件目录,字符串名称){
return!file.getName().equals(name)
}
}).each{otherfile->
List otherLines=otherfile.readLines()
lines.each{line->
如果(其他行。包含(行)){
新文件('Double replicate.txt')
new File('/path/to/folder/with/your/duplicate/files').listFiles().each { file ->
    List<String> lines = file.readLines()
    new File('/path/to/folder/with/your/duplicate/files').listFiles(new FilenameFilter() {
        @Override
        boolean accept(File dir, String name) {
            return !file.getName().equals(name)
        }
    }).each { otherfile ->
        List<String> otherLines = otherfile.readLines()
        lines.each { line ->
            if (otherLines.contains(line)) {
                new File('Double Duplicate.txt') << line << ' ('<< file.getName() << ' & ' << otherfile.getName() << ')' << System.getProperty('line.separator')
            }
        }
    }
}