public static String trimStringByString(String text, String trimBy) {
int beginIndex = 0;
int endIndex = text.length();
while (text.substring(beginIndex, endIndex).startsWith(trimBy)) {
beginIndex += trimBy.length();
}
while (text.substring(beginIndex, endIndex).endsWith(trimBy)) {
endIndex -= trimBy.length();
}
return text.substring(0, endIndex);
}
public static String padLeft(String in, int size, char padChar) {
if (in.length() <= size) {
char[] temp = new char[size];
/* Llenado Array con el padChar*/
for(int i =0;i<size;i++){
temp[i]= padChar;
}
int posIniTemp = size-in.length();
for(int i=0;i<in.length();i++){
temp[posIniTemp]=in.charAt(i);
posIniTemp++;
}
return new String(temp);
}
return "";
}
No comments:
Post a Comment