String initData = "N.O.\t1,2,3,4,5,6,7,8,9"; String[] items = initData.split("[\\s]"); for (int i = 1; i < items.length; i++) { Object[] head = ArrayUtils.subarray(items, 1, i); Object[] tail = ArrayUtils.subarray(items, i + 1, items.length); String v = StringUtils.join(ArrayUtils.addAll(head, tail), ","); System.out.println(items[i] + " : " + v); }
denpendency:
- common-lang
原始数据:
N.O. 1,2,3,4,5,6,7,8,9
结果:
1 : 2,3,4,5,6,7,8,9
2 : 1,3,4,5,6,7,8,9
3 : 1,2,4,5,6,7,8,9
4 : 1,2,3,5,6,7,8,9
5 : 1,2,3,4,6,7,8,9
6 : 1,2,3,4,5,7,8,9
7 : 1,2,3,4,5,6,8,9
8 : 1,2,3,4,5,6,7,9
9 : 1,2,3,4,5,6,7,8