You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/11/21 08:38:47 UTC

[GitHub] [commons-lang] arturobernalg commented on a change in pull request #645: [LANG-1614] - Split fixed-length elements

arturobernalg commented on a change in pull request #645:
URL: https://github.com/apache/commons-lang/pull/645#discussion_r528168674



##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -7731,6 +7731,48 @@ public static String rotate(final String str, final int shift) {
         return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
     }
 
+    /**
+     * Split a {@link String} into a {@code String []} of fixed-length elements.
+     *
+     * <pre>
+     * StringUtils.splitEvery("test1",10)             = ["test1"]
+     * StringUtils.splitEvery("test2", 4)             = ["test","2"]
+     * StringUtils.splitEvery("testAbgTestsABG", -2)  = ["testAbgTestsABG"]
+     * StringUtils.splitEvery("",10)                  = [""]
+     * StringUtils.splitEvery(null,4)                 = {@code null}
+     * StringUtils.splitEvery("testAbgTestsABG",2)    = ["te","st","Ab","gT","es","ts","AB","G"]
+     * </pre>
+     *
+     * @param str {@link String} to split into fixed length elements.
+     * @param length length of the elements into which the String will be divided.
+     * @return a {@code String []} of fixed-length elements.
+     */
+    public static String[] splitEvery( final String str, final int length ) {

Review comment:
       Hi 
   
   usually in the others method return null . An. example of that -->
   
   `  public static String abbreviateMiddle(final String str, final String middle, final int length) {
           if (isAnyEmpty(str, middle) || length >= str.length() || length < middle.length()+2) {
               return str;
           }`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org