Java String Split by Length splitString(String s, int maxSize)

Here you can find the source of splitString(String s, int maxSize)

Description

split String

License

Open Source License

Declaration

public static List<String> splitString(String s, int maxSize) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static List<String> splitString(String s, int maxSize) {
        List<String> linesOfMaxSize = new ArrayList<String>();
        int i = 0;
        while (i < s.length()) {
            linesOfMaxSize.add(s.substring(i, Math.min(i + maxSize, s.length())));
            i += maxSize;//from  ww w  .j  a v  a2  s .  c  om
        }
        return linesOfMaxSize;
    }
}

Related

  1. splitIntoLine(String input, int maxCharInLine)
  2. splitLines(String paragraph, int lineLength)
  3. splitParams(String string, int max)
  4. splitPreserveAllTokens(String str, String separatorChars, int max)
  5. splitString(String orig, String delim, int max)
  6. splitString(String str, int length)
  7. splitString(String str, int length)
  8. splitString(String string, int maxCharsPerLine)
  9. splitString(String stringToSplit, int maxLength)