String replaceSubString(String orignal, int startIndex, int endIndex, String replaceWith){
StringBuffer buffer = new StringBuffer(orignal);
if ((action.getEndindex() - action.getStartindex()) < 0) {
if (replaceWith.length() > (startIndex - endIndex)) {
throw new RuntimeException("Replace string lenght not same as difference of start & end index.");
}
buffer = buffer.replace(endIndex, startIndex, replaceWith);
} else {
if (replaceWith.length() > (endIndex - startIndex)) {
throw new RuntimeException("Replace string lenght not same as difference of start & end index.");
}
buffer = buffer.replace(startIndex, endIndex, replaceWith);
}
return buffer.toString();
}
Hi, This is my code, while I test it for the quality of the code, it shows “Detect and throw a highlighted exception instead of using a generic”, what should I do to solve this problem? Can anyone help me with this.
source
share