Added a convenience method.

This change is originally from pull request #682.
This commit is contained in:
Kohsuke Kawaguchi committed 2013-02-28 17:33:36 -08:00
1 parent 902edc38aa
commit 00bfa35651
2 files changed
+20 -2

No files matched your search

+19
View File
@@ -513,6 +513,25 @@ public class Util {
else return s;
}
/**
* Ensure string ends with suffix
*
* @param subject Examined string
* @param suffix Desired suffix
* @return Original subject in case it already ends with suffix, null in
* case subject was null and subject + suffix otherwise.
* @since 1.505
*/
public static String ensureEndsWith(String subject, String suffix) {
if (subject == null) return null;
if (subject.endsWith(suffix)) return subject;
return subject + suffix;
}
/**
* Computes MD5 digest of the given input stream.
*