The list of methods to do String Split by Length are organized into topic(s).
String[]
getSplitLines(String input, int maxLineLength) get Split Lines
List<String> lines = new ArrayList<String>();
if (maxLineLength > 0 && input.length() > maxLineLength) {
int cutPos;
do {
cutPos = getCutOffPosition(input, maxLineLength);
String text;
if (cutPos > 0) {
text = input.substring(0, cutPos).trim();
...
List
lineSplit(String text, int len)
Splits a string on word boundries.
if (text == null) {
return new ArrayList<>();
if (len <= 0 || text.length() <= len) {
return new ArrayList<>(Arrays.asList(new String[] { text }));
char[] chars = text.toCharArray();
List<String> lines = new ArrayList<>();
...
List
split(final String value, final int maxLength) split
final List parts = new ArrayList(23);
final int originalLength = value.length();
if (originalLength > maxLength) {
final int splitCount = originalLength / maxLength;
for (int splitIndex = 0; splitIndex < splitCount; splitIndex++) {
parts.add(value.substring(splitIndex * maxLength, (splitIndex + 1) * maxLength));
final int leftOverLength = originalLength - splitCount * maxLength;
...
List
split(String message, int maxPages, int pageSize)
Helper method to split a string by pages and page size
List<String> result = new ArrayList<String>(maxPages);
for (int page = 0; page < maxPages; page++) {
int startIndex = page * pageSize;
int endIndex = (page + 1) * pageSize;
if (endIndex < message.length()) {
result.add(message.substring(startIndex, endIndex));
} else {
result.add(message.substring(startIndex));
...
List
splitArray(byte[] array, int len)
split Array
int length = array.length;
List<byte[]> list = new ArrayList<byte[]>();
if (length <= len) {
list.add(array);
return list;
int size = length / len;
for (int i = 0; i < size; i++) {
...
String[]
splitByLength(String string, int len) split By Length
if (string == null || len <= 0)
return null;
if (string.length() < len) {
String[] arr = new String[1];
arr[0] = string;
return arr;
int chunks = string.length() / len + ((string.length() % len > 0) ? 1 : 0);
...
List
splitByteArray(byte[] inByteArray, int length)
split Byte Array
if (inByteArray == null)
return null;
List<byte[]> rtnList = new ArrayList<byte[]>();
if (length >= inByteArray.length) {
rtnList.add(inByteArray);
rtnList.add(null);
return rtnList;
byte[] firstPart = new byte[length];
System.arraycopy(inByteArray, 0, firstPart, 0, length);
byte[] seconPart = new byte[inByteArray.length - length];
System.arraycopy(inByteArray, length, seconPart, 0, inByteArray.length - length);
rtnList.add(firstPart);
rtnList.add(seconPart);
return rtnList;
List
splitByteArray(final byte[] data, final int packetLength)
Splits a byte array into smaller chunks
List<byte[]> split = new ArrayList<byte[]>();
int wholePackets = (int) (data.length / packetLength);
int index = 0;
for (int i = 0; i < wholePackets; i++) {
byte[] dataPacket = new byte[packetLength];
for (int j = 0; j < packetLength; j++) {
dataPacket[j] = data[index];
index++;
...