本文整理了Java中java.lang.StringBuilder.indexOf()
方法的一些代码示例,展示了StringBuilder.indexOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.indexOf()
方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:indexOf
暂无
代码示例来源:origin: pockethub/PocketHub
private static StringBuilder strip(final StringBuilder input,
final String prefix, final String suffix) {
int start = input.indexOf(prefix);
while (start != -1) {
int end = input.indexOf(suffix, start + prefix.length());
if (end == -1) {
end = input.length();
}
input.delete(start, end + suffix.length());
start = input.indexOf(prefix, start);
}
return input;
}
代码示例来源:origin: pockethub/PocketHub
private static boolean replace(final StringBuilder input,
final String from, final String to) {
int start = input.indexOf(from);
if (start == -1) {
return false;
}
final int fromLength = from.length();
final int toLength = to.length();
while (start != -1) {
input.replace(start, start + fromLength, to);
start = input.indexOf(from, start + toLength);
}
return true;
}
代码示例来源:origin: stackoverflow.com
public static void replaceAll(StringBuilder builder, String from, String to)
{
int index = builder.indexOf(from);
while (index != -1)
{
builder.replace(index, index + from.length(), to);
index += to.length(); // Move to the end of the replacement
index = builder.indexOf(from, index);
}
}
代码示例来源:origin: h2oai/h2o-2
static private void subsub( StringBuilder sb, String s1, String s2 ) {
int idx;
while( (idx=sb.indexOf(s1)) != -1 ) sb.replace(idx,idx+2,s2);
}
代码示例来源:origin: hibernate/hibernate-orm
private static String getJavaAttributeNameFromXMLOne(String attributeName) {
StringBuilder annotationAttributeName = new StringBuilder( attributeName );
int index = annotationAttributeName.indexOf( WORD_SEPARATOR );
while ( index != -1 ) {
annotationAttributeName.deleteCharAt( index );
annotationAttributeName.setCharAt(
index, Character.toUpperCase( annotationAttributeName.charAt( index ) )
);
index = annotationAttributeName.indexOf( WORD_SEPARATOR );
}
return annotationAttributeName.toString();
}
代码示例来源:origin: lets-blade/blade
private static String takeUntilDotOrEnd(StringBuilder buff) {
final int firstPointIdx = buff.indexOf(".");
String result;
if (-1 == firstPointIdx) {
result = buff.toString();
buff.setLength(0);
} else {
result = buff.substring(0, firstPointIdx);
buff.delete(0, firstPointIdx + 1);
}
return result;
}
代码示例来源:origin: lets-blade/blade
private static String takeUntilDotOrEnd(StringBuilder buff) {
final int firstPointIdx = buff.indexOf(".");
String result;
if (-1 == firstPointIdx) {
result = buff.toString();
buff.setLength(0);
} else {
result = buff.substring(0, firstPointIdx);
buff.delete(0, firstPointIdx + 1);
}
return result;
}
代码示例来源:origin: aws/aws-sdk-java
public static String replace( String originalString, String partToMatch, String replacement ) {
StringBuilder buffer = new StringBuilder( originalString.length() );
buffer.append( originalString );
int indexOf = buffer.indexOf( partToMatch );
while (indexOf != -1) {
buffer = buffer.replace(indexOf, indexOf + partToMatch.length(), replacement);
indexOf = buffer.indexOf(partToMatch, indexOf + replacement.length());
}
return buffer.toString();
}
代码示例来源:origin: redisson/redisson
public Builder(String path, boolean encodePath, String encoding) {
this.encoding = encoding;
url = new StringBuilder();
if (encodePath) {
url.append(encodeUri(path, encoding));
} else {
url.append(path);
}
this.hasParams = url.indexOf(StringPool.QUESTION_MARK) != -1;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Append the query string of the current request to the target redirect URL.
* @param targetUrl the StringBuilder to append the properties to
* @param request the current request
* @since 4.1
*/
protected void appendCurrentQueryParams(StringBuilder targetUrl, HttpServletRequest request) {
String query = request.getQueryString();
if (StringUtils.hasText(query)) {
// Extract anchor fragment, if any.
String fragment = null;
int anchorIndex = targetUrl.indexOf("#");
if (anchorIndex > -1) {
fragment = targetUrl.substring(anchorIndex);
targetUrl.delete(anchorIndex, targetUrl.length());
}
if (targetUrl.toString().indexOf('?') < 0) {
targetUrl.append('?').append(query);
}
else {
targetUrl.append('&').append(query);
}
// Append anchor fragment, if any, to end of URL.
if (fragment != null) {
targetUrl.append(fragment);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
int searchIndex = 0;
while (searchIndex != -1) {
int keyStart = sb.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX, searchIndex);
searchIndex = -1;
if (keyStart != -1) {
int keyEnd = sb.indexOf(
PropertyAccessor.PROPERTY_KEY_SUFFIX, keyStart + PropertyAccessor.PROPERTY_KEY_PREFIX.length());
if (keyEnd != -1) {
代码示例来源:origin: aws/aws-sdk-java
protected static String replaceChar(String value, String termToFind, String replacementTerm) {
StringBuilder buffer = new StringBuilder(value);
int searchIndex = 0;
while (searchIndex < buffer.length()) {
searchIndex = buffer.indexOf(termToFind, searchIndex);
if (searchIndex == -1) {
break;
} else {
buffer.replace(searchIndex, searchIndex + termToFind.length(), replacementTerm);
searchIndex += replacementTerm.length();
}
}
return buffer.toString();
}
代码示例来源:origin: amitshekhariitbhu/Android-Debug-Database
private String removeComments(final String sql) {
StringBuilder sb = new StringBuilder(sql);
int nextCommentPosition = sb.indexOf(TOKEN_SINGLE_LINE_COMMENT);
while (nextCommentPosition > -1) {
int end = indexOfRegex(TOKEN_NEWLINE, sb.substring(nextCommentPosition));
if (end == -1) {
return sb.substring(0, nextCommentPosition);
} else {
sb.replace(nextCommentPosition, end + nextCommentPosition, "");
}
nextCommentPosition = sb.indexOf(TOKEN_SINGLE_LINE_COMMENT);
}
return sb.toString();
}
代码示例来源:origin: oblac/jodd
public Builder(final String path, final boolean encodePath, final String encoding) {
this.encoding = encoding;
url = new StringBuilder();
if (encodePath) {
url.append(encodeUri(path, encoding));
} else {
url.append(path);
}
this.hasParams = url.indexOf(StringPool.QUESTION_MARK) != -1;
}
代码示例来源:origin: MovingBlocks/Terasology
private static String getCheckboxNameFor(StandardModuleExtension standardModuleExtension) {
StringBuilder builder = new StringBuilder(standardModuleExtension.getKey());
final int prefixIndex = builder.indexOf("is");
if (prefixIndex == 0) {
builder.delete(prefixIndex, prefixIndex + 2);
builder.setCharAt(0, Character.toLowerCase(builder.charAt(0)));
}
return builder.append("Checkbox").toString();
}
}
代码示例来源:origin: immutables/immutables
Other replace(String search, String replacement) {
StringBuilder builder = new StringBuilder(this);
int index = builder.indexOf(search);
if (index < 0) {
return this;
}
builder.replace(index, index + search.length(), replacement);
return new Other(builder.toString());
}
代码示例来源:origin: spring-projects/spring-framework
int anchorIndex = targetUrl.indexOf("#");
if (anchorIndex > -1) {
fragment = targetUrl.substring(anchorIndex);
代码示例来源:origin: spring-projects/spring-framework
url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));
代码示例来源:origin: ReactiveX/RxJava
int index = 0;
for (;;) {
int idx = sourceCode.indexOf(annotation, index);
int k = sourceCode.indexOf(inDoc, j);
int ll = sourceCode.indexOf("You specify", k);
int lm = sourceCode.indexOf("This operator", k);
if ((ll < 0 || ll > idx) && (lm < 0 || lm > idx)) {
int n = sourceCode.indexOf("{@code ", k);
int endDD = sourceCode.indexOf("</dd>", k);
int m = sourceCode.indexOf("}", n);
int q = sourceCode.indexOf("@SuppressWarnings({", idx);
int o = sourceCode.indexOf("{", idx);
o = sourceCode.indexOf("{", q + 20);
int p = sourceCode.indexOf(" " + mname + "(", idx);
代码示例来源:origin: ReactiveX/RxJava
static final void scanFor(StringBuilder sourceCode, String annotation, String inDoc,
StringBuilder e, String baseClassName) {
int index = 0;
for (;;) {
int idx = sourceCode.indexOf(annotation, index);
if (idx < 0) {
break;
}
int j = sourceCode.lastIndexOf("/**", idx);
// see if the last /** is not before the index (last time the annotation was found
// indicating an uncommented method like subscribe()
if (j > index) {
int k = sourceCode.indexOf(inDoc, j);
if (k < 0 || k > idx) {
// when printed on the console, IDEs will create a clickable link to help navigate to the offending point
e.append("java.lang.RuntimeException: missing ").append(inDoc).append(" section\r\n")
;
int lc = lineNumber(sourceCode, idx);
e.append(" at io.reactivex.").append(baseClassName)
.append(" (").append(baseClassName).append(".java:")
.append(lc).append(")").append("\r\n\r\n");
}
}
index = idx + annotation.length();
}
}
内容来源于网络,如有侵权,请联系作者删除!