Java List Difference formatDifferentFileNames(List results)

Here you can find the source of formatDifferentFileNames(List results)

Description

format Different File Names

License

Open Source License

Declaration

public static List<String> formatDifferentFileNames(List<String> results) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

public class Main {
    private static final String IS_NOT_EXIST = "is not exist";
    private static final int FIXED_LENGTH = 40;

    public static List<String> formatDifferentFileNames(List<String> results) {
        List<String> ret = new ArrayList<String>();
        List<String> l1 = new ArrayList<String>();
        List<String> l2 = new ArrayList<String>();
        for (String str : results) {
            if (isContainNotExist(str)) {
                l1.add(str);/*from  w ww .j  a  va  2s. com*/
            } else {
                l2.add(str);
            }
        }
        Collections.sort(l1);
        Collections.sort(l2);
        ret.addAll(l2);
        if (l1.size() > 0 && l2.size() > 0) {
            ret.add(fillWithChar('=', 0, ""));
            ret.addAll(l1);
        }
        return ret;
    }

    public static boolean isContainNotExist(String str) {
        return str.indexOf(IS_NOT_EXIST) >= 0;
    }

    private static String fillWithChar(char c, int file_length,
            String baseSuffix) {
        StringBuilder sb = new StringBuilder();
        int num = FIXED_LENGTH - file_length + baseSuffix.length();
        System.out.println(" cur len = " + file_length + " fill num = "
                + num);
        for (int i = 0; i < num; i++) {
            sb.append(c);
        }
        return sb.toString();
    }
}

Related

  1. diffFloats(List a, List b)
  2. diffList(List aList, List bList)
  3. diffSet(List a, List b)
  4. diffSimple(String name, Object expected, Object actual, List messages)
  5. extractDifference(List l1, List l2, List in1not2, List in2not1, List inBothFrom1, List inBothFrom2, Comparator c)
  6. getDiffentElement(List minList, List maxList)
  7. getDifference(List bigger, List smaller)
  8. getDiffInfo(List infoList)
  9. getLeftDiff(List list1, List list2)