当先锋百科网

首页 1 2 3 4 5 6 7

版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创!

恰饭广告

import java.io.IOException;

import java.util.ArrayList;

import java.util.HashSet;

import java.util.List;

import java.util.stream.Collectors;

public class ListHelper {

public static boolean isExcelRepeat(String excelFileName, int... args) {

try {

ArrayList> arr = ExcelHelper.getExcel(excelFileName, args);

int oldRow = arr.size();

int newRow = removeRepeatLow(arr).size();

// int newRow1 = removeRepeatHeight(arr).size();

if (oldRow != newRow) {

return true;

}

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return false;

}

public static ArrayList> removeRepeatLow(ArrayList> list) {

HashSet hs = new HashSet(list);

list.clear();

list.addAll(hs);

return list;

}

public static ArrayList> removeRepeatHeight(ArrayList> list) {

ArrayList> arr = (ArrayList>) list.stream().distinct()

.collect(Collectors.toList());

return arr;

}

public static List> splitList(List list, int pageSize) {

int listSize = list.size();

int page = (listSize + (pageSize - 1)) / pageSize;

List> listArray = new ArrayList>();

for (int i = 0; i < page; i++) {

List subList = new ArrayList();

for (int j = 0; j < listSize; j++) {

int pageIndex = ((j + 1) + (pageSize - 1)) / pageSize;

if (pageIndex == (i + 1)) {

subList.add(list.get(j));

}

if ((j + 1) == ((j + 1) * pageSize)) {

break;

}

}

listArray.add(subList);

}

return listArray;

}

}

让我恰个饭吧.ヘ( ̄ω ̄ヘ)

支付宝 ——————- 微信

恰饭广告

b2fa10417bcbd2c397d3c42ce544672e.gif