Java String Split split(final int limit, String text)

Here you can find the source of split(final int limit, String text)

Description

split

License

Open Source License

Declaration

public static ArrayList<String> split(final int limit, String text) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static ArrayList<String> split(final int limit, String text) {
        final ArrayList<String> splits = new ArrayList<String>();
        if (text.length() > limit) {
            while (text.length() > limit) {
                final String sub = text.substring(0, limit);
                final int lastSpace = sub.lastIndexOf(" ");
                text = text.substring(lastSpace + 1);
                splits.add(sub);/*from   www. j  ava2  s  .  com*/
            }
            return splits;
        }
        splits.add(text);
        return splits;
    }
}

Related

  1. split(byte[] bytes, byte[] p)
  2. split(byte[] data)
  3. split(byte[] input)
  4. split(byte[] input)
  5. split(final byte[] array, final int chunkSize)
  6. split(final String s)
  7. split(final String s)
  8. split(final String s)
  9. split(final String str)