fix for StringIndexOutOfBoundsException caused by overlong string passed to titleize(String str)
This commit is contained in:
parent
2f61e83a8a
commit
86112380da
@ -12,7 +12,11 @@ public class TextUtil {
|
|||||||
int pivot = line.length() / 2;
|
int pivot = line.length() / 2;
|
||||||
int eatLeft = center.length() / 2;
|
int eatLeft = center.length() / 2;
|
||||||
int eatRight = center.length() - eatLeft;
|
int eatRight = center.length() - eatLeft;
|
||||||
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
|
|
||||||
|
if (eatLeft < pivot)
|
||||||
|
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
|
||||||
|
else
|
||||||
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String repeat(String s, int times) {
|
public static String repeat(String s, int times) {
|
||||||
|
Loading…
Reference in New Issue
Block a user