public void compareApks() {
        System.out.println("Starting to compare apks...");
        
        PrintWriter writer = null;
        try {
            writer = new PrintWriter(outputFilePath, "UTF-8");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return;
        }
        
        ArrayList<ApkFileAttributes> apkAttrs1;
        ArrayList<ApkFileAttributes> apkAttrs2;
        
        ApkFileAttributes apkAttrI, apkAttrJ;
        double jaccardSim;
        boolean sameCerts;
        HashSet<String> hashesI, hashesJ;
        int ilen, jlen;
        int filesNum1, filesNum2;
        String outLine;
        
        long timeStart, timeEnd, totalTimeMem, totalTimeCompare;
        
        if (in2 != null) {
            //getting attributes to memory
            timeStart = System.nanoTime();
            apkAttrs1 = getApkAttributesToMemory(in1);
            apkAttrs2 = getApkAttributesToMemory(in2);
            timeEnd = System.nanoTime();
            totalTimeMem = timeEnd - timeStart;
            
            filesNum1 = apkAttrs1.size();
            filesNum2 = apkAttrs2.size();
            
            timeStart = System.nanoTime();
            for (int i = 0; i < filesNum1; i++) {
                apkAttrI = apkAttrs1.get(i);
                hashesI = new HashSet<String>(apkAttrI.getFileHashMap().values());
                ilen = hashesI.size();
                for (int j = 0; j < filesNum2; j++) {
                    apkAttrJ = apkAttrs2.get(j);
                    hashesJ = new HashSet<String>(apkAttrJ.getFileHashMap().values());
                    jlen = hashesJ.size();
                    jaccardSim = PairComparator.getJaccardIndex(hashesI, hashesJ);
//                    if (jaccardSim == 0) {
//                        continue;
//                    }
                    sameCerts = PairComparator.certsTheSame(apkAttrI, apkAttrJ);
                    outLine = createOutString(apkAttrI.getApkName(), apkAttrJ.getApkName(), ilen, jlen, jaccardSim, sameCerts);
                    writer.println(outLine);
                }
                //System.out.println(String.valueOf(i) + " th file [" + apkAttrI.getApkName() + "] compared with others!");
            }
            timeEnd = System.nanoTime();
            totalTimeCompare = timeEnd - timeStart;
            
        } else {
            timeStart = System.nanoTime();
            
            apkAttrs1 = getApkAttributesToMemory(in1);
            
            timeEnd = System.nanoTime();
            totalTimeMem = timeEnd - timeStart;
            
            filesNum1 = apkAttrs1.size();
            
            timeStart = System.nanoTime();
            for (int i = 0; i < filesNum1; i++) {
                apkAttrI = apkAttrs1.get(i);
                hashesI = new HashSet<String>(apkAttrI.getFileHashMap().values());
                ilen = hashesI.size();
                for (int j = i + 1; j < filesNum1; j++) {
                    apkAttrJ = apkAttrs1.get(j);
                    hashesJ = new HashSet<String>(apkAttrJ.getFileHashMap().values());
                    jlen = hashesJ.size();
                    jaccardSim = PairComparator.getJaccardIndex(hashesI, hashesJ);
//                    if (jaccardSim == 0) {
//                        continue;
//                    }
                    sameCerts = PairComparator.certsTheSame(apkAttrI, apkAttrJ);
                    outLine = createOutString(apkAttrI.getApkName(), apkAttrJ.getApkName(), ilen, jlen, jaccardSim, sameCerts);
                    writer.println(outLine);
                }
                //System.out.println(String.valueOf(i) + " th file [" + apkAttrI.getApkName() + "] compared with others!");
            }
            timeEnd = System.nanoTime();
            totalTimeCompare = timeEnd - timeStart;
            
        }
        System.out.println("Getting apk attributes to memory took: " + 
                totalTimeMem / (1000*1000) + "ms");
        System.out.println("Comparing apk attributes took: " + 
                totalTimeCompare / (1000*1000) + "ms");
        
        writer.close();
    }