本文整理了Java中java.lang.StringBuffer.setLength()
方法的一些代码示例,展示了StringBuffer.setLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.setLength()
方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:setLength
暂无
代码示例来源:origin: log4j/log4j
protected String stackTraceToString(Throwable t) {
String s = null;
synchronized (sw) {
t.printStackTrace(pw);
s = sw.toString();
sw.getBuffer().setLength(0);
}
return s;
}
代码示例来源:origin: apache/incubator-dubbo
private String readLenString(int len)
throws IOException {
_isLastChunk = true;
_chunkLength = len;
_sbuf.setLength(0);
int ch;
while ((ch = parseChar()) >= 0)
_sbuf.append((char) ch);
return _sbuf.toString();
}
代码示例来源:origin: jenkinsci/jenkins
private void reset() {
StringBuffer buf = getStringBuffer();
if (buf.length()>4096)
out = new StringWriter(256);
else
buf.setLength(0);
}
代码示例来源:origin: google/j2objc
public void visitEnd() {
buf.setLength(0);
buf.append("av").append(id).append(".visitEnd();\n");
text.add(buf.toString());
}
}
代码示例来源:origin: google/j2objc
public void visitIincInsn(final int var, final int increment) {
buf.setLength(0);
buf.append("mv.visitIincInsn(")
.append(var)
.append(", ")
.append(increment)
.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: apache/incubator-dubbo
private String readLenString()
throws IOException {
int len = readInt();
_isLastChunk = true;
_chunkLength = len;
_sbuf.setLength(0);
int ch;
while ((ch = parseChar()) >= 0)
_sbuf.append((char) ch);
return _sbuf.toString();
}
代码示例来源:origin: google/j2objc
public void visitMaxs(final int maxStack, final int maxLocals) {
buf.setLength(0);
buf.append(tab2).append("MAXSTACK = ").append(maxStack).append('\n');
text.add(buf.toString());
buf.setLength(0);
buf.append(tab2).append("MAXLOCALS = ").append(maxLocals).append('\n');
text.add(buf.toString());
if (mv != null) {
mv.visitMaxs(maxStack, maxLocals);
}
}
代码示例来源:origin: apache/zookeeper
/**
* Check if we are ready to send another chunk.
* @param force force sending, even if not a full chunk
*/
private void checkFlush(boolean force) {
if ((force && sb.length() > 0) || sb.length() > 2048) {
sendBufferSync(ByteBuffer.wrap(sb.toString().getBytes()));
// clear our internal buffer
sb.setLength(0);
}
}
代码示例来源:origin: apache/zookeeper
/**
* Check if we are ready to send another chunk.
* @param force force sending, even if not a full chunk
*/
private void checkFlush(boolean force) {
if ((force && sb.length() > 0) || sb.length() > 2048) {
sendBuffer(ByteBuffer.wrap(sb.toString().getBytes()));
// clear our internal buffer
sb.setLength(0);
}
}
代码示例来源:origin: google/j2objc
public void visitTypeInsn(final int opcode, final String type) {
buf.setLength(0);
buf.append("mv.visitTypeInsn(").append(OPCODES[opcode]).append(", ");
appendConstant(type);
buf.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: google/j2objc
public void visitMultiANewArrayInsn(final String desc, final int dims) {
buf.setLength(0);
buf.append("mv.visitMultiANewArrayInsn(");
appendConstant(desc);
buf.append(", ").append(dims).append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: google/j2objc
public void visitLdcInsn(final Object cst) {
buf.setLength(0);
buf.append("mv.visitLdcInsn(");
appendConstant(cst);
buf.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: google/j2objc
public void visitLineNumber(final int line, final Label start) {
buf.setLength(0);
buf.append("mv.visitLineNumber(").append(line).append(", ");
appendLabel(start);
buf.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: google/j2objc
public void visitTypeInsn(final int opcode, final String type) {
buf.setLength(0);
buf.append(tab2).append(OPCODES[opcode]).append(' ');
appendDescriptor(INTERNAL_NAME, type);
buf.append('\n');
text.add(buf.toString());
if (mv != null) {
mv.visitTypeInsn(opcode, type);
}
}
代码示例来源:origin: google/j2objc
public void visitJumpInsn(final int opcode, final Label label) {
buf.setLength(0);
declareLabel(label);
buf.append("mv.visitJumpInsn(").append(OPCODES[opcode]).append(", ");
appendLabel(label);
buf.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: google/j2objc
public void visitJumpInsn(final int opcode, final Label label) {
buf.setLength(0);
buf.append(tab2).append(OPCODES[opcode]).append(' ');
appendLabel(label);
buf.append('\n');
text.add(buf.toString());
if (mv != null) {
mv.visitJumpInsn(opcode, label);
}
}
代码示例来源:origin: google/j2objc
public void visitLabel(final Label label) {
buf.setLength(0);
declareLabel(label);
buf.append("mv.visitLabel(");
appendLabel(label);
buf.append(");\n");
text.add(buf.toString());
}
代码示例来源:origin: log4j/log4j
protected
void addConverter(PatternConverter pc) {
currentLiteral.setLength(0);
// Add the pattern converter to the list.
addToList(pc);
// Next pattern is assumed to be a literal.
state = LITERAL_STATE;
// Reset formatting info
formattingInfo.reset();
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Reads a header, returning null if there are no headers.
* <p>
* <pre>
* H b16 b8 value
* </pre>
*/
@Override
public String readHeader()
throws IOException {
int tag = read();
if (tag == 'H') {
_isLastChunk = true;
_chunkLength = (read() << 8) + read();
_sbuf.setLength(0);
int ch;
while ((ch = parseChar()) >= 0)
_sbuf.append((char) ch);
return _sbuf.toString();
}
_peek = tag;
return null;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Parses a type from the stream.
* <p>
* <pre>
* t b16 b8
* </pre>
*/
@Override
public String readType()
throws IOException {
int code = read();
if (code != 't') {
_peek = code;
return "";
}
_isLastChunk = true;
_chunkLength = (read() << 8) + read();
_sbuf.setLength(0);
int ch;
while ((ch = parseChar()) >= 0)
_sbuf.append((char) ch);
return _sbuf.toString();
}
内容来源于网络,如有侵权,请联系作者删除!