split string Equally - Android java.lang

Android examples for java.lang:String Split

Description

split string Equally

Demo Code

import java.util.ArrayList;
import java.util.List;

public class Main{

    public static List<String> splitEqually(String text, int size) {
        List<String> ret = new ArrayList<String>((text.length() + size - 1)
                / size);//from   www .ja v a2 s  .  c  o m

        for (int start = 0; start < text.length(); start += size) {
            ret.add(text.substring(start,
                    Math.min(text.length(), start + size)));
        }
        return ret;
    }

}

Related Tutorials