I recently wrote a program that reads a plain text file, and compares every line and alerts you if any are similar, based on a float value that you pass in to a function.import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.*;public class DuplicateLineFinder {    public static void main(String[] args) throws IOException {        final float SIMILARITY_RATE = 0.75f;        String fileLocation = System.getProperty(user.home) + /Desktop/;        String fileName = lines.txt;        BufferedReader file = new BufferedReader(new FileReader(fileLocation + fileName));        List<String> lines = new ArrayList<String>();        String line;        while((line = file.readLine()) != null) {            lines.add(line);        }         for (int i = 0; i < lines.size()-2; i++) {            for (int j = i+1; j < lines.size()-1; j++) {                if (IsSimilar(lines.get(i), lines.get(j), SIMILARITY_RATE))                    System.out.println(WARNING!\n  + lines.get(i) + \n and \n + lines.get(j) + \n might be the same);            }        }        file.close();    }    public static boolean IsSimilar(String line1, String line2, float percentSimilar) {        int duplicateWordCount = 0;        List<String> words1 = new LinkedList<String>(Arrays.asList(line1.split( )));        List<String> words2 = new LinkedList<String>(Arrays.asList(line2.split( )));        if (words1.size() >= words2.size()) {            for (String word : words2) {                if (words1.remove(word)) {                    duplicateWordCount++;                }            }            if (duplicateWordCount > (words2.size() * percentSimilar)) return true;        }        else if (words2.size() > words1.size()) {            for (String word : words1) {                if (words2.remove(word)) {                    duplicateWordCount++;                }            }            if (duplicateWordCount > (words1.size() * percentSimilar)) return true;        }        return false;    }}It works well, and is customisable in case you want to make it more/less strict. I am wondering if there is a better way to do my if statements in the IsSimilar function, as without them it doesn't work as well.
Duplicate Line Finder
java;algorithm;strings;file;edit distance