本文整理了Java中java.lang.StringBuffer.indexOf()
方法的一些代码示例,展示了StringBuffer.indexOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.indexOf()
方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:indexOf
暂无
代码示例来源:origin: log4j/log4j
/**
* Abbreviate name.
* @param buf buffer to append abbreviation.
* @param nameStart start of name to abbreviate.
*/
public void abbreviate(final int nameStart, final StringBuffer buf) {
int i = count;
for(int pos = buf.indexOf(".", nameStart);
pos != -1;
pos = buf.indexOf(".", pos + 1)) {
if(--i == 0) {
buf.delete(nameStart, pos + 1);
break;
}
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Returns true if this CDATA section contains the illegal character
* sequence "]]>". Such nodes must be {@link #split} before they are
* serialized.
*/
public boolean needsSplitting() {
return buffer.indexOf("]]>") != -1;
}
代码示例来源:origin: robovm/robovm
/**
* Returns true if this comment contains the illegal character sequence
* "--". Such nodes may not be serialized.
*/
public boolean containsDashDash() {
return buffer.indexOf("--") != -1;
}
}
代码示例来源:origin: ctripcorp/apollo
/**
* filter out the first comment line
* @param stringBuffer the string buffer
* @return true if filtered successfully, false otherwise
*/
static boolean filterPropertiesComment(StringBuffer stringBuffer) {
//check whether has comment in the first line
if (stringBuffer.charAt(0) != '#') {
return false;
}
int commentLineIndex = stringBuffer.indexOf("\n");
if (commentLineIndex == -1) {
return false;
}
stringBuffer.delete(0, commentLineIndex + 1);
return true;
}
}
代码示例来源:origin: pentaho/pentaho-kettle
private int replaceHolder( StringBuffer dateBuffer, Boolean inPattern ) {
String placeHolder = inPattern ? ESCAPED_NANOSECOND_PLACEHOLDER : NANOSECOND_PLACEHOLDER;
int placeholderPosition = dateBuffer.indexOf( placeHolder );
if ( placeholderPosition == -1 ) {
return 0;
}
dateBuffer.delete( placeholderPosition, placeholderPosition + placeHolder.length() );
return placeholderPosition;
}
代码示例来源:origin: iMeiji/Toutiao
/**
* Unicode编码转汉字
*/
public static String UnicodeToChs(String s) {
StringBuffer sb = new StringBuffer(s);
int pos;
while ((pos = sb.indexOf("\\u")) > -1) {
String tmp = sb.substring(pos, pos + 6);
sb.replace(pos, pos + 6, Character.toString((char) Integer.parseInt(tmp.substring(2), 16)));
}
s = sb.toString();
return s;
}
}
代码示例来源:origin: oblac/jodd
/**
* Detects if session ID exist in the URL. It works more reliable
* than <code>servletRequest.isRequestedSessionIdFromURL()</code>.
*/
protected boolean isRequestedSessionIdFromURL(final HttpServletRequest servletRequest) {
if (servletRequest.isRequestedSessionIdFromURL()) {
return true;
}
HttpSession session = servletRequest.getSession(false);
if (session != null) {
String sessionId = session.getId();
StringBuffer requestUri = servletRequest.getRequestURL();
return requestUri.indexOf(sessionId) != -1;
}
return false;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Performs the replace operation.
* @return The position of the last character that was inserted as
* replacement.
*/
private int replace() {
String t = getToken();
int found = inputBuffer.indexOf(t);
int pos = -1;
final int tokenLength = t.length();
final int replaceValueLength = replaceValue.length();
while (found >= 0) {
inputBuffer.replace(found, found + tokenLength, replaceValue);
pos = found + replaceValueLength;
found = inputBuffer.indexOf(t, pos);
++replaceCount;
}
return pos;
}
}
代码示例来源:origin: commons-io/commons-io
if (xmlProlog.substring(0, 5).equals("<?xml")) {
final int xmlPrologEnd = xmlProlog.indexOf("?>");
if (xmlPrologEnd > 0) {
代码示例来源:origin: Dreampie/Resty
public String getNextWord() {
Random rnd = new Random();
StringBuffer sb = new StringBuffer();
StringBuffer chars = new StringBuffer(characters);
int l = minLength + (maxLength > minLength ? rnd.nextInt(maxLength - minLength) : 0);
for (int i = 0; i < l; i++) {
int j = rnd.nextInt(chars.length());
char c = chars.charAt(j);
if (wideCharacters.indexOf(c) != -1) {
for (int k = 0; k < wideCharacters.length(); k++) {
int idx = chars.indexOf(String.valueOf(wideCharacters.charAt(k)));
if (idx != -1) {
chars.deleteCharAt(idx);
}
}
}
sb.append(c);
}
return sb.toString();
}
代码示例来源:origin: stackoverflow.com
String tagOpen = "<double>";
String tagClose = "</double>";
if (respStr.indexOf(tagOpen) != -1) {
int start = respStr.indexOf(tagOpen) + tagOpen.length();
int end = respStr.indexOf(tagClose);
String value = respStr.substring(start, end);
result = Double.parseDouble(value);
代码示例来源:origin: stackoverflow.com
String tagOpen = "<elevation>";
String tagClose = "</elevation>";
if (respStr.indexOf(tagOpen) != -1) {
int start = respStr.indexOf(tagOpen) + tagOpen.length();
int end = respStr.indexOf(tagClose);
String value = respStr.substring(start, end);
result = (double)(Double.parseDouble(value)*3.2808399); // convert from meters to feet
代码示例来源:origin: org.apache.poi/poi
private void writeFractional(StringBuffer result, StringBuffer output) {
int digit;
int strip;
if (fractionalSpecials.size() > 0) {
String decimalSeparator = Character.toString(getDecimalFormatSymbols().getDecimalSeparator());
digit = result.indexOf(decimalSeparator) + 1;
if (exponent != null) {
strip = result.indexOf("e") - 1;
} else {
strip = result.length() - 1;
}
while (strip > digit && result.charAt(strip) == '0') {
strip--;
}
for (Special s : fractionalSpecials) {
char resultCh = result.charAt(digit);
if (resultCh != '0' || s.ch == '0' || digit < strip) {
output.setCharAt(s.pos, resultCh);
} else if (s.ch == '?') {
// This is when we're in trailing zeros, and the format is '?'.
// We still strip out remaining '#'s later
output.setCharAt(s.pos, ' ');
}
digit++;
}
}
}
代码示例来源:origin: sonyxperiadev/ApkAnalyser
/**
* Outputs to the final destination as many full line pairs as
* there are in the pending output, removing those lines from
* their respective buffers. This method terminates when at
* least one of the two column buffers is empty.
*/
private void outputFullLines() throws IOException {
for (;;) {
int leftLen = leftBuf.indexOf("\n");
if (leftLen < 0) {
return;
}
int rightLen = rightBuf.indexOf("\n");
if (rightLen < 0) {
return;
}
if (leftLen != 0) {
out.write(leftBuf.substring(0, leftLen));
}
if (rightLen != 0) {
writeSpaces(out, leftWidth - leftLen);
out.write(rightBuf.substring(0, rightLen));
}
out.write('\n');
leftBuf.delete(0, leftLen + 1);
rightBuf.delete(0, rightLen + 1);
}
}
代码示例来源:origin: apache/geode
private String extractSessionId() {
final int prefix = getRequestURL().indexOf(URL_SESSION_IDENTIFIER);
if (prefix != -1) {
final int start = prefix + URL_SESSION_IDENTIFIER.length();
int suffix = getRequestURL().indexOf("?", start);
if (suffix < 0) {
suffix = getRequestURL().indexOf("#", start);
}
if (suffix <= prefix) {
return getRequestURL().substring(start);
}
return getRequestURL().substring(start, suffix);
}
return null;
}
}
代码示例来源:origin: kiegroup/jbpm
if (buf.indexOf("where") == -1) {
operand = " where ";
代码示例来源:origin: org.codehaus.plexus/plexus-utils
int xmlPrologEnd = xmlProlog.indexOf( "?>" );
if ( xmlPrologEnd > 0 )
代码示例来源:origin: org.apache.poi/poi
String groupingSeparator = Character.toString(dfs.getGroupingSeparator());
int pos = result.indexOf(decimalSeparator) - 1;
if (pos < 0) {
if (exponent != null && numSpecials == integerSpecials) {
pos = result.indexOf("E") - 1;
} else {
pos = result.length() - 1;
代码示例来源:origin: org.apache.poi/poi
while ((pos = fmt.indexOf("''", pos)) >= 0) {
fmt.delete(pos, pos + 2);
while ((pos = fmt.indexOf("\u0000", pos)) >= 0) {
fmt.replace(pos, pos + 1, "''");
代码示例来源:origin: thinkaurelius/titan
int pos = 0;
while (pos<qB.length()) {
pos = qB.indexOf(prefix,pos);
if (pos<0) break;
内容来源于网络,如有侵权,请联系作者删除!