commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-348) Add StringUtils.repeat with separator
Date Fri, 13 Jul 2007 15:24:04 GMT

    [ https://issues.apache.org/jira/browse/LANG-348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512515
] 

Henri Yandell commented on LANG-348:
------------------------------------

Logically it would be:

public static String repeat(String str, char separatorChar, int repeat) {
    String[] array = new String[repeat];
    Collections.fill(array, str);
    return join(array, separatorChar);
}

And maybe an overload for String separatorChar. 

The hack I would probably just use instead is:

    StringUtils.repeat(str + separatorStr, repeat).removeEnd(separatorStr);


> Add StringUtils.repeat with separator
> -------------------------------------
>
>                 Key: LANG-348
>                 URL: https://issues.apache.org/jira/browse/LANG-348
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Kees van Dieren
>            Priority: Minor
>
> I would like to have a repeat method with the ability to set a separator:
> public static String repeat(String str, char separatorChar, int repeat)
> Usage scenario: generate insert statements for JDBC preparedstatements:
> assertEquals("?,?,?,?", StringUtils.repeat("?", ',', 4));
> Can this be added to commons-lang?
> Thanks!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message