Here you can find the source of splitStringOnFields(String in, int[] cuts)
public static String[] splitStringOnFields(String in, int[] cuts)
//package com.java2s; //License from project: Apache License import java.util.*; import java.util.List; public class Main { public static String[] splitStringOnFields(String in, int[] cuts) { char[] data = in.toCharArray(); List holder = new ArrayList(); for (int i = 0; i < cuts.length; i++) { int start = cuts[i]; int count = data.length - start; if (i < cuts.length - 1) { count = cuts[i + 1] - start; }/*from w w w . ja v a 2 s . c o m*/ String item = new String(data, start, count); holder.add(item); } String[] ret = new String[holder.size()]; holder.toArray(ret); return (ret); } }