mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
Implements String.delete(char oldChar, String newChar), StringBuffer and
StringBuilder delete(int startIndex, int endIndex), and replace (int startIndex, int endIndex, String replacementString)
This commit is contained in:
@ -148,6 +148,15 @@ public class StringBuilder {
|
||||
return insert(i, new String(new char[] { c }, 0, 1, false));
|
||||
}
|
||||
|
||||
public StringBuilder delete(int start, int end) {
|
||||
int numChars = end - start; // Do not delete end itself
|
||||
while (numChars > 0) {
|
||||
deleteCharAt(start);
|
||||
numChars--;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder deleteCharAt(int i) {
|
||||
if (i < 0 || i >= length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -185,6 +194,12 @@ public class StringBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringBuilder replace(int start, int end, String str) {
|
||||
delete(start, end);
|
||||
insert(start, str);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
|
Reference in New Issue
Block a user