本文整理了Java中java.lang.StringBuilder.setLength()
方法的一些代码示例,展示了StringBuilder.setLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.setLength()
方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:setLength
[英]Sets the length of this string buffer.
[中]
代码示例来源:origin: spring-projects/spring-framework
public void write(char ch) {
if (ch == '\n' && this.buffer.length() > 0) {
logger.debug(this.buffer.toString());
this.buffer.setLength(0);
}
else {
this.buffer.append(ch);
}
}
代码示例来源:origin: apache/incubator-dubbo
public void write(char ch) {
if (ch == '\n' && _sb.length() > 0) {
_log.log(_level, _sb.toString());
_sb.setLength(0);
} else
_sb.append((char) ch);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void write(char[] buffer, int offset, int length) {
for (int i = 0; i < length; i++) {
char ch = buffer[offset + i];
if (ch == '\n' && _sb.length() > 0) {
_log.log(_level, _sb.toString());
_sb.setLength(0);
} else
_sb.append((char) ch);
}
}
代码示例来源:origin: apache/incubator-dubbo
public void write(char ch) {
if (ch == '\n' && _sb.length() > 0) {
_log.log(_level, _sb.toString());
_sb.setLength(0);
} else
_sb.append((char) ch);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void write(char[] buffer, int offset, int length) {
for (int i = 0; i < length; i++) {
char ch = buffer[offset + i];
if (ch == '\n' && _sb.length() > 0) {
_log.log(_level, _sb.toString());
_sb.setLength(0);
} else
_sb.append((char) ch);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void write(char[] buffer, int offset, int length) {
for (int i = 0; i < length; i++) {
char ch = buffer[offset + i];
if (ch == '\n' && this.buffer.length() > 0) {
logger.debug(this.buffer.toString());
this.buffer.setLength(0);
}
else {
this.buffer.append(ch);
}
}
}
代码示例来源:origin: square/okhttp
Entry(String key) {
this.key = key;
lengths = new long[valueCount];
cleanFiles = new File[valueCount];
dirtyFiles = new File[valueCount];
// The names are repetitive so re-use the same builder to avoid allocations.
StringBuilder fileBuilder = new StringBuilder(key).append('.');
int truncateTo = fileBuilder.length();
for (int i = 0; i < valueCount; i++) {
fileBuilder.append(i);
cleanFiles[i] = new File(directory, fileBuilder.toString());
fileBuilder.append(".tmp");
dirtyFiles[i] = new File(directory, fileBuilder.toString());
fileBuilder.setLength(truncateTo);
}
}
代码示例来源:origin: netty/netty
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: libgdx/libgdx
/** Returns a description of the actor hierarchy, recursively. */
public String toString () {
StringBuilder buffer = new StringBuilder(128);
toString(buffer, 1);
buffer.setLength(buffer.length() - 1);
return buffer.toString();
}
代码示例来源:origin: libgdx/libgdx
@Override
public void println (String s) {
buf.append(s);
consoleLog(buf.toString());
buf.setLength(0);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void println (String s) {
buf.append(s);
consoleLog(buf.toString());
buf.setLength(0);
}
代码示例来源:origin: libgdx/libgdx
/** Returns a description of the actor hierarchy, recursively. */
public String toString () {
StringBuilder buffer = new StringBuilder(128);
toString(buffer, 1);
buffer.setLength(buffer.length() - 1);
return buffer.toString();
}
代码示例来源:origin: netty/netty
public void reset() {
timeFound = false;
hours = -1;
minutes = -1;
seconds = -1;
dayOfMonthFound = false;
dayOfMonth = -1;
monthFound = false;
month = -1;
yearFound = false;
year = -1;
cal.clear();
sb.setLength(0);
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public String nextToken(String delim)
throws NoSuchElementException
{
_delim=delim;
_i=_lastStart;
_token.setLength(0);
_hasToken=false;
return nextToken();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public String nextToken()
throws NoSuchElementException
{
if (!hasMoreTokens() || _token==null)
throw new NoSuchElementException();
String t=_token.toString();
_token.setLength(0);
_hasToken=false;
return t;
}
代码示例来源:origin: libgdx/libgdx
@Override
public String toString () {
stringBuilder.setLength(0);
for (final ObjectMap.Entry<String, ObjectMap<String, String>> entry : snippets.entries()) {
stringBuilder.append(entry.key).append(": {");
for (final String snipname : entry.value.keys())
stringBuilder.append(snipname).append(", ");
stringBuilder.append("}\n");
}
return stringBuilder.toString();
}
}
代码示例来源:origin: netty/netty
@Override
public String toString() {
StringBuilder buf = new StringBuilder(super.toString());
buf.setLength(buf.length() - 1);
buf.append(", resolver: ").append(resolver());
SocketAddress remoteAddress = remoteAddress();
if (remoteAddress != null) {
buf.append(", remoteAddress: ")
.append(remoteAddress);
}
return buf.append(')').toString();
}
}
代码示例来源:origin: libgdx/libgdx
public ShaderProgram load (String vertex, String fragment) {
StringBuilder out = new StringBuilder();
load(out, vertex);
vertex = out.toString();
includes.clear();
out.setLength(0);
load(out, fragment);
fragment = out.toString();
includes.clear();
return new ShaderProgram(vertex, fragment);
}
代码示例来源:origin: libgdx/libgdx
public void render (boolean update) {
fpsCounter.put(Gdx.graphics.getFramesPerSecond());
if (update) update();
beginRender(true);
renderWorld();
Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
if (debugMode != DebugDrawModes.DBG_NoDebug) world.setDebugMode(debugMode);
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
performance.setLength(0);
performance.append("FPS: ").append(fpsCounter.value).append(", Bullet: ")
.append((int)(performanceCounter.load.value * 100f)).append("%");
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType,
ServerWebExchange exchange) {
StringBuilder builder = new StringBuilder();
builder.append("name=").append(this.name).append('\n');
for (Map.Entry<String, ?> entry : model.entrySet()) {
builder.append(entry.getKey()).append('=').append(entry.getValue()).append('\n');
}
builder.setLength(builder.length() - 1);
byte[] bytes = builder.toString().getBytes(StandardCharsets.UTF_8);
ServerHttpResponse response = exchange.getResponse();
DataBuffer buffer = response.bufferFactory().wrap(bytes);
response.getHeaders().setContentType(MediaType.TEXT_PLAIN);
return response.writeWith(Mono.just(buffer));
}
}
内容来源于网络,如有侵权,请联系作者删除!