Java Array Split splitStringOnFields(String in, int[] cuts)

Here you can find the source of splitStringOnFields(String in, int[] cuts)

Description

split String On Fields

License

Apache License

Declaration

public static String[] splitStringOnFields(String in, int[] cuts) 

Method Source Code

//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);
    }
}

Related

  1. splitByteArray(byte[] array, int each)
  2. splitByteArray(byte[] inByteArray, int length)
  3. splitData(String[] sData, int numMaps)
  4. splitOrderByFirst(byte[] pattern, byte[] src, int offset)
  5. splitSentences(String[] sentence, int limitLength, String reg)
  6. splitWordsL(String s, boolean splitOnWs, char[] delimiters)
  7. unsplit(String[] array, String seperator)