Java String Chop chop(String value, int size)

Here you can find the source of chop(String value, int size)

Description

CHOP

License

Open Source License

Declaration


public static final String[] chop(String value, int size) 

Method Source Code

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

public class Main {
    /**/*from  w w w .ja v a 2  s  . co  m*/
     * CHOP
     */

    public static final String[] chop(String value, int size) {
        int fullParts = value.length() / size;
        int extra = ((value.length() % size) != 0) ? 1 : 0;

        String[] part = new String[fullParts + extra];

        for (int i = 0; i < fullParts; i++)
            part[i] = value.substring(i * size, (i + 1) * size);

        if (extra != 0)
            part[fullParts] = value.substring(fullParts * size);

        return part;
    }
}

Related

  1. chop(String str)
  2. chop(String str)
  3. chop(String str, int maxLength)
  4. chop(String string, int length)
  5. chop(String string, int length)
  6. chop(String x)
  7. chop(String[] arr, int pos)
  8. chop(StringBuffer buffer, int chars)
  9. chopAccelerator(final String title)