本文整理了Java中java.lang.StringBuffer.substring()
方法的一些代码示例,展示了StringBuffer.substring()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.substring()
方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:substring
暂无
代码示例来源:origin: org.apache.ant/ant
/**
* Get the current text for the element.
*
* @return the current text.
*/
public String getText() {
return text.substring(0);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* get the eof string.
* @return the eof string.
*/
public String getEofStr() {
return eofStr.substring(0);
}
代码示例来源:origin: neo4j/neo4j
private String baseURL( HttpServletRequest request )
{
StringBuffer url = request.getRequestURL();
String baseURL = url.substring( 0, url.length() - request.getRequestURI().length() ) + "/";
return XForwardUtil.externalUri(
baseURL,
request.getHeader( X_FORWARD_HOST_HEADER_KEY ),
request.getHeader( X_FORWARD_PROTO_HEADER_KEY ) );
}
代码示例来源:origin: smuyyh/BookReader
private String toHexString(int v, int len) {
StringBuffer b = new StringBuffer();
for (int i = 0; i < len; i++)
b.append('0');
b.append(Long.toHexString(v));
return b.substring(b.length() - len).toUpperCase();
}
代码示例来源:origin: robovm/robovm
private boolean regionMatch(StringBuffer string, int index, String test) {
boolean matches = false;
if( index >= 0 &&
(index + test.length() - 1) < string.length() ) {
String substring = string.substring( index, index + test.length());
matches = substring.equals( test );
}
return matches;
}
代码示例来源:origin: cloudfoundry/uaa
private String getContextPath(HttpServletRequest request) {
StringBuffer requestURL = request.getRequestURL();
return requestURL.substring(0, requestURL.length() - request.getServletPath().length());
}
}
代码示例来源:origin: cloudfoundry/uaa
private String getServerContextPath(HttpServletRequest request) {
StringBuffer requestURL = request.getRequestURL();
return requestURL.substring(0, requestURL.length() - request.getServletPath().length());
}
代码示例来源:origin: robovm/robovm
public String substringData(int offset, int count) throws DOMException {
try {
return buffer.substring(offset, offset + count);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, null);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Changes the password to '***' so it isn't displayed on screen if the build fails
*
* @param cmd The command line to clean
* @return The command line as a string with out the password
*/
private String formatCommandLine(Commandline cmd) {
StringBuffer sBuff = new StringBuffer(cmd.toString());
int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN);
if (indexUser > 0) {
int indexPass = sBuff.substring(0).indexOf(",", indexUser);
int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass);
for (int i = indexPass + 1; i < indexAfterPass; i++) {
sBuff.setCharAt(i, '*');
}
}
return sBuff.toString();
}
代码示例来源: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: pentaho/pentaho-kettle
/**
* Replace value occurances in a String with another value.
*
* @param string
* The original String.
* @param repl
* The text to replace
* @param with
* The new text bit
* @return The resulting string with the text pieces replaced.
*/
public static final String replace( String string, String repl, String with ) {
StringBuffer str = new StringBuffer( string );
for ( int i = str.length() - 1; i >= 0; i-- ) {
if ( str.substring( i ).startsWith( repl ) ) {
str.delete( i, i + repl.length() );
str.insert( i, with );
}
}
return str.toString();
}
代码示例来源:origin: commons-io/commons-io
if (xmlProlog.substring(0, 5).equals("<?xml")) {
final Matcher m = ENCODING_PATTERN.matcher(xmlProlog.substring(0,
xmlPrologEnd));
if (m.find()) {
代码示例来源:origin: knowm/XChange
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isTextual()) {
return node.textValue();
} else if (node.isObject()) {
JsonNode allNode = node.get("__all__");
if (allNode != null && allNode.isArray()) {
StringBuffer buf = new StringBuffer();
for (JsonNode msgNode : allNode) {
buf.append(msgNode.textValue());
buf.append(",");
}
return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
}
return node.toString();
}
return null;
}
}
代码示例来源:origin: knowm/XChange
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (node.isTextual()) {
return node.textValue();
} else if (node.isObject()) {
JsonNode allNode = node.get("__all__");
if (allNode != null && allNode.isArray()) {
StringBuffer buf = new StringBuffer();
for (JsonNode msgNode : allNode) {
buf.append(msgNode.textValue());
buf.append(",");
}
return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
}
return node.toString();
}
return null;
}
}
代码示例来源:origin: googleapis/google-cloud-java
private String getTestOutput(HttpServletRequest req, HttpServletResponse resp) {
synchronized (executor) {
if (testRunner != null) {
resp.setContentType("text");
return testRunner.getOutput();
}
resp.setContentType("text/html");
int urlUriLenDiff = req.getRequestURL().length() - req.getRequestURI().length();
String link = req.getRequestURL().substring(0, urlUriLenDiff);
return "Test hasn't been started yet. Go to <a href='"
+ link
+ "'>"
+ link
+ "</a> to start a new test";
}
}
代码示例来源:origin: plantuml/plantuml
public String getStringAt(Cell cell, int length){
int x = cell.x;
int y = cell.y;
if(x > getWidth() - 1
|| y > getHeight() - 1
|| x < 0
|| y < 0) return null;
return rows.get(y).substring(x, x + length);
}
代码示例来源: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: apache/ignite
/**
* Append StringBuffer
*
* @param sb StringBuffer to append.
* @return Reference to this object.
*/
public CircularStringBuilder append(StringBuffer sb) {
if (sb == null)
return appendNull();
int len = sb.length();
if (len < value.length)
append(sb.toString());
else {
skipped += len - value.length;
append(sb.substring(len - value.length));
}
return this;
}
代码示例来源:origin: org.apache.ant/ant
/**
* get the next element.
* @return the next element.
* @throws NoSuchElementException if there is no more.
*/
@Override
public Object nextElement()
throws NoSuchElementException {
if (!hasMoreElements()) {
throw new NoSuchElementException("OneLiner");
}
BufferLine tmpLine =
new BufferLine(line.toString(), eolStr.substring(0));
nextLine();
return tmpLine;
}
代码示例来源:origin: smuyyh/BookReader
@Override
protected void onBindData(final EasyRVHolder holder, final int position, final BooksByTag.TagBook item) {
StringBuffer sbTags = new StringBuffer();
for (String tag : item.tags) {
if (!TextUtils.isEmpty(tag)) {
sbTags.append(tag);
sbTags.append(" | ");
}
}
holder.setRoundImageUrl(R.id.ivBookCover, Constant.IMG_BASE_URL + item.cover, R.drawable.cover_default)
.setText(R.id.tvBookListTitle, item.title)
.setText(R.id.tvShortIntro, item.shortIntro)
.setText(R.id.tvTags, (item.tags.size() == 0 ? "" : sbTags.substring(0, sbTags
.lastIndexOf(" | "))));
holder.setOnItemViewClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemClickListener.onItemClick(holder.getItemView(), position, item);
}
});
}
}
内容来源于网络,如有侵权,请联系作者删除!