Created
September 1, 2017 23:30
-
-
Save jeffersonlicet/e5fdfd2eef00969b55f1f3a8c5f129da to your computer and use it in GitHub Desktop.
Recursive left string padding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add padding to a String | |
* | |
* @param String to process | |
* @param int len to achieve | |
* @param String to append as padding | |
* @return String processed string | |
*/ | |
public static String addPadding(String input, int maxLen, String append) { | |
if (input.length() >= maxLen) { | |
return input; | |
} else { | |
return addPadding(append + input, maxLen); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment