All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.firemage.autograder.cmd.StringUtil Maven / Gradle / Ivy

There is a newer version: 0.6.2
Show newest version
package de.firemage.autograder.cmd;

public final class StringUtil {
    private StringUtil() {

    }

    public static String center(String s, int length, String padding) {
        if (padding.length() != 1) {
            throw new IllegalArgumentException("padding must be a string of length 1");
        }
        return length > s.length()
                ? padding.repeat((length - s.length()) / 2) + s + padding.repeat((length - s.length() + 1) / 2)
                : s;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy