Here you can find the source of splitEqually(String _text, int _len)
Parameter | Description |
---|---|
_text | text to split |
_len | max length per line |
public static List<String> splitEqually(String _text, int _len)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w . j a v a 2 s. c o m * Splits a Text to equal parts. * There is no detection of words, everything will be cut to the same length. * * @param _text text to split * @param _len max length per line * @return list of string splitted to _len or null if _text was null */ public static List<String> splitEqually(String _text, int _len) { if (_text == null) { return null; } List<String> ret = new ArrayList<String>((_text.length() + _len - 1) / _len); for (int start = 0; start < _text.length(); start += _len) { ret.add(_text.substring(start, Math.min(_text.length(), start + _len))); } return ret; } }