java8 Stream 合并流 逆操作 分组 自定义(按个数)分组

package com.cmcc.coc.cbpsp.activities.service;

import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {

	public static void main(String[] args) throws InterruptedException, ExecutionException {
	}

	private Function, Stream> batches = map -> {
		final Temp temp = new Temp();
		return map.entrySet()
				.stream()
				.map(en -> en.getKey())
				.collect(Collectors.groupingBy(i -> String.valueOf(temp.a++ / 10), Collectors.joining(";")))
				.entrySet()
				.stream()
				.map(en -> en.getValue());
	};
	
	class Temp {
		int a=0;
	}
}

 

你可能感兴趣的:(java)