本文整理了Java中java.lang.StringBuffer.setCharAt()
方法的一些代码示例,展示了StringBuffer.setCharAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.setCharAt()
方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:setCharAt
暂无
代码示例来源:origin: log4j/log4j
/**
* Formats a count of milliseconds (0-999) into a numeric representation.
* @param millis Millisecond coun between 0 and 999.
* @param buf String buffer, may not be null.
* @param offset Starting position in buffer, the length of the
* buffer must be at least offset + 3.
*/
private static void millisecondFormat(
final int millis, final StringBuffer buf, final int offset) {
buf.setCharAt(offset, DIGITS.charAt(millis / 100));
buf.setCharAt(offset + 1, DIGITS.charAt((millis / 10) % 10));
buf.setCharAt(offset + 2, DIGITS.charAt(millis % 10));
}
代码示例来源:origin: org.apache.poi/poi
public void finish(StringBuffer toAppendTo) {
if (hStart >= 0 && !showAmPm) {
for (int i = 0; i < hLen; i++) {
toAppendTo.setCharAt(hStart + i, 'H');
}
}
}
}
代码示例来源:origin: log4j/log4j
public static String capitalize(String name) {
if (Character.isLowerCase(name.charAt(0))) {
if (name.length() == 1 || Character.isLowerCase(name.charAt(1))) {
StringBuffer newname = new StringBuffer(name);
newname.setCharAt(0, Character.toUpperCase(name.charAt(0)));
return newname.toString();
}
}
return name;
}
代码示例来源:origin: redisson/redisson
private CtClass lookupClass0(String classname, boolean notCheckInner)
throws NotFoundException
{
CtClass cc = null;
do {
try {
cc = classPool.get(classname);
}
catch (NotFoundException e) {
int i = classname.lastIndexOf('.');
if (notCheckInner || i < 0)
throw e;
else {
StringBuffer sbuf = new StringBuffer(classname);
sbuf.setCharAt(i, '$');
classname = sbuf.toString();
}
}
} while (cc == null);
return cc;
}
代码示例来源:origin: JetBrains/ideavim
@NotNull
public CharPointer set(char ch, int offset) {
if (seq == null) {
return this;
}
if (readonly) {
throw new IllegalStateException("readonly string");
}
StringBuffer data = (StringBuffer)seq;
while (pointer + offset >= data.length()) {
data.append('\u0000');
}
data.setCharAt(pointer + offset, ch);
return this;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Translates occurrences at a position of / or \ to correct separator of the
* current platform and returns whether it had to do a
* replacement.
* @param buffer a buffer containing a string
* @param pos the position in the string buffer to convert
* @return true if the character was a / or \
*/
protected static boolean translateFileSep(StringBuffer buffer, int pos) {
if (buffer.charAt(pos) == '/' || buffer.charAt(pos) == '\\') {
buffer.setCharAt(pos, File.separatorChar);
return true;
}
return false;
}
代码示例来源:origin: log4j/log4j
/**
* Gets HEADER portion of packet.
* @param timeStamp number of milliseconds after the standard base time.
* @return HEADER portion of packet, will be zero-length string if header is false.
* @since 1.2.15
*/
private String getPacketHeader(final long timeStamp) {
if (header) {
StringBuffer buf = new StringBuffer(dateFormat.format(new Date(timeStamp)));
// RFC 3164 says leading space, not leading zero on days 1-9
if (buf.charAt(4) == '0') {
buf.setCharAt(4, ' ');
}
buf.append(getLocalHostname());
buf.append(' ');
return buf.toString();
}
return "";
}
代码示例来源:origin: log4j/log4j
buffer.setCharAt(i, ' ');
代码示例来源:origin: pentaho/pentaho-kettle
public String stripCR( StringBuffer sbsql ) {
// DB2 Can't handle \n in SQL Statements...
if ( !supportsNewLinesInSQL() ) {
// Remove CR's
for ( int i = sbsql.length() - 1; i >= 0; i-- ) {
if ( sbsql.charAt( i ) == '\n' || sbsql.charAt( i ) == '\r' ) {
sbsql.setCharAt( i, ' ' );
}
}
}
return sbsql.toString();
}
代码示例来源:origin: org.apache.ant/ant
/**
* returns the unicode representation of a char without the leading backslash
* @param ch a character
* @return unicode representation of a char for property files
*/
public static StringBuffer EscapeUnicode(char ch) {
StringBuffer unicodeBuf = new StringBuffer("u0000");
String s = Integer.toHexString(ch);
//replace the last 0s by the chars contained in s
for (int i = 0; i < s.length(); i++) {
unicodeBuf.setCharAt(unicodeBuf.length()
- s.length() + i,
s.charAt(i));
}
return unicodeBuf;
}
}
代码示例来源:origin: redisson/redisson
private static String lookupSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("lookupswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int npairs = iter.s32bitAt(index += 4);
int end = npairs * 8 + (index += 4);
for (; index < end; index += 8) {
int match = iter.s32bitAt(index);
int target = iter.s32bitAt(index + 4) + pos;
buffer.append("\t\t").append(match).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: redisson/redisson
private static String tableSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("tableswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int low = iter.s32bitAt(index += 4);
int high = iter.s32bitAt(index += 4);
int end = (high - low + 1) * 4 + (index += 4);
// Offset table
for (int key = low; index < end; index += 4, key++) {
int target = iter.s32bitAt(index) + pos;
buffer.append("\t\t").append(key).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: plantuml/plantuml
public void set(int x, int y, char c){
if(x > getWidth() - 1 || y > getHeight() - 1) return;
StringBuffer row = rows.get(y);
row.setCharAt(x, c);
}
代码示例来源:origin: org.javassist/javassist
private static String lookupSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("lookupswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int npairs = iter.s32bitAt(index += 4);
int end = npairs * 8 + (index += 4);
for (; index < end; index += 8) {
int match = iter.s32bitAt(index);
int target = iter.s32bitAt(index + 4) + pos;
buffer.append("\t\t").append(match).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: org.javassist/javassist
private static String tableSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("tableswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int low = iter.s32bitAt(index += 4);
int high = iter.s32bitAt(index += 4);
int end = (high - low + 1) * 4 + (index += 4);
// Offset table
for (int key = low; index < end; index += 4, key++) {
int target = iter.s32bitAt(index) + pos;
buffer.append("\t\t").append(key).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: scouter-project/scouter
private static String lookupSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("lookupswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int npairs = iter.s32bitAt(index += 4);
int end = npairs * 8 + (index += 4);
for (; index < end; index += 8) {
int match = iter.s32bitAt(index);
int target = iter.s32bitAt(index + 4) + pos;
buffer.append("\t\t").append(match).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: scouter-project/scouter
private static String lookupSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("lookupswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int npairs = iter.s32bitAt(index += 4);
int end = npairs * 8 + (index += 4);
for (; index < end; index += 8) {
int match = iter.s32bitAt(index);
int target = iter.s32bitAt(index + 4) + pos;
buffer.append("\t\t").append(match).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: scouter-project/scouter
private static String tableSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("tableswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int low = iter.s32bitAt(index += 4);
int high = iter.s32bitAt(index += 4);
int end = (high - low + 1) * 4 + (index += 4);
// Offset table
for (int key = low; index < end; index += 4, key++) {
int target = iter.s32bitAt(index) + pos;
buffer.append("\t\t").append(key).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: scouter-project/scouter
private static String tableSwitch(CodeIterator iter, int pos) {
StringBuffer buffer = new StringBuffer("tableswitch {\n");
int index = (pos & ~3) + 4;
// default
buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n");
int low = iter.s32bitAt(index += 4);
int high = iter.s32bitAt(index += 4);
int end = (high - low + 1) * 4 + (index += 4);
// Offset table
for (int key = low; index < end; index += 4, key++) {
int target = iter.s32bitAt(index) + pos;
buffer.append("\t\t").append(key).append(": ").append(target).append("\n");
}
buffer.setCharAt(buffer.length() - 1, '}');
return buffer.toString();
}
代码示例来源:origin: log4j/log4j
for (int i = 0; i < sbuf.length(); i++) {
if (sbuf.charAt(i) >= 0x80) {
sbuf.setCharAt(i, '?');
内容来源于网络,如有侵权,请联系作者删除!