Skip to content

Instantly share code, notes, and snippets.

@jeffersonlicet
Created September 1, 2017 23:30
Show Gist options
  • Save jeffersonlicet/e5fdfd2eef00969b55f1f3a8c5f129da to your computer and use it in GitHub Desktop.
Save jeffersonlicet/e5fdfd2eef00969b55f1f3a8c5f129da to your computer and use it in GitHub Desktop.
Recursive left string padding
/**
* 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