java.lang.StringBuffer.delete()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中java.lang.StringBuffer.delete()方法的一些代码示例,展示了StringBuffer.delete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuffer.delete()方法的具体详情如下:
包路径:java.lang.StringBuffer
类名称:StringBuffer
方法名:delete

StringBuffer.delete介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

public void deleteData(int offset, int count) throws DOMException {
  buffer.delete(offset, offset + count);
}

代码示例来源: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: 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: jersey/jersey

public void clear() { // DELETE
  content.delete(0, content.length());
}

代码示例来源:origin: stackoverflow.com

StringBuffer sb = new StringBuffer();
for (int n = 0; n < 10; n++) {
  sb.append("a");

  // This will clear the buffer
  sb.delete(0, sb.length());
}

代码示例来源: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) {
  // We substract 1 from 'len' when assigning to 'end' to avoid out of
  // bounds exception in return r.substring(end+1, len). This can happen if
  // precision is 1 and the category name ends with a dot.
  int end = buf.length() - 1;
  String bufString = buf.toString();
  for (int i = count; i > 0; i--) {
   end = bufString.lastIndexOf(".", end - 1);
   if ((end == -1) || (end < nameStart)) {
    return;
   }
  }
  buf.delete(nameStart, end + 1);
 }
}

代码示例来源: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: log4j/log4j

/**
  * Abbreviate element of name.
  * @param buf buffer to receive element.
  * @param startPos starting index of name element.
  * @return starting index of next element.
  */
 public int abbreviate(final StringBuffer buf, final int startPos) {
  int nextDot = buf.toString().indexOf(".", startPos);
  if (nextDot != -1) {
   if ((nextDot - startPos) > charCount) {
    buf.delete(startPos + charCount, nextDot);
    nextDot = startPos + charCount;
    if (ellipsis != '\0') {
     buf.insert(nextDot, ellipsis);
     nextDot++;
    }
   }
   nextDot++;
  }
  return nextDot;
 }
}

代码示例来源:origin: jersey/jersey

public void setContent(String replacement) { // PUT
  content.delete(0, content.length()).append(replacement);
}

代码示例来源:origin: cSploit/android

@Override
 public void onNewLine(String line) {
  sb.delete(0, sb.length());
  sb.append(line);
 }
});

代码示例来源:origin: org.apache.ant/ant

/**
 * Writes the buffer as far as possible.
 * @return false to be inline with the Replacefilter.
 * (Yes defining an interface crossed my mind, but would publish the
 * internal behavior.)
 * @throws IOException when the output cannot be written.
 */
boolean process() throws IOException {
  writer.write(inputBuffer.toString());
  inputBuffer.delete(0, inputBuffer.length());
  return false;
}

代码示例来源:origin: cSploit/android

@Override
public void onStart(String command) {
 mErrorOutput.delete(0, mErrorOutput.length());
 mErrorOutput.append("running: ");
 mErrorOutput.append(command);
 mErrorOutput.append("\n");
}

代码示例来源:origin: log4j/log4j

buffer.delete(fieldStart, buffer.length() - maxLength);
} else if (rawLength < minLength) {
 if (leftAlign) {

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

@Override
public void internalStartElement(String elemName, HashMap mapMandatory, HashMap mapAllowed)
throws SAXException {
  String temp;
  fileName.delete(0, fileName.length());
  temp = (String) mapMandatory.get("NAME"); // NOI18N
  if (temp == null) {
    temp = (String) mapMandatory.get("name"); // NOI18N
  }
  if (temp != null) {
    fileName.append(temp);
  }
}

代码示例来源:origin: apache/geode

@Override
public String toString() {
 StringBuffer sb = new StringBuffer();
 for (Map.Entry<String, Exception> entry : this.exceptionsMap.entrySet()) {
  sb.append("Creation of index: ").append(entry.getKey()).append(" failed due to: ")
    .append(entry.getValue()).append(", ");
 }
 sb.delete(sb.length() - 2, sb.length());
 return sb.toString();
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Processes the buffer to the end. Does not take into account that
 * appended data may make it possible to replace the end of the already
 * received data.
 */
void flush() {
  replace();
  outputBuffer.append(inputBuffer);
  inputBuffer.delete(0, inputBuffer.length());
}

代码示例来源:origin: pentaho/pentaho-kettle

public void doAppend( LoggingEvent event ) {
 String line = layout.format( event ) + Const.CR;
 buffer.append( line );
 // See if we don't have too many lines on board...
 nrLines++;
 if ( maxNrLines > 0 && nrLines > maxNrLines ) {
  buffer.delete( 0, line.length() );
  nrLines--;
 }
 for ( BufferChangedListener listener : bufferChangedListeners ) {
  listener.contentWasAdded( buffer, line, nrLines );
 }
}

代码示例来源:origin: apache/hbase

/**
 * Get backup request meta data dir as string.
 * @param backupInfo backup info
 * @return meta data dir
 */
protected String obtainBackupMetaDataStr(BackupInfo backupInfo) {
 StringBuffer sb = new StringBuffer();
 sb.append("type=" + backupInfo.getType() + ",tablelist=");
 for (TableName table : backupInfo.getTables()) {
  sb.append(table + ";");
 }
 if (sb.lastIndexOf(";") > 0) {
  sb.delete(sb.lastIndexOf(";"), sb.lastIndexOf(";") + 1);
 }
 sb.append(",targetRootDir=" + backupInfo.getBackupRootDir());
 return sb.toString();
}

代码示例来源:origin: spring-projects/spring-loaded

protected String printItAndReturnIt(byte[] classdata, boolean quoted) {
  OutputStream os = new SimpleOutputStream();
  ClassReader reader = new ClassReader(classdata);
  reader.accept(new ClassPrinter(new PrintStream(os)), 0);
  StringBuffer sb = new StringBuffer(os.toString().replace("\r", ""));
  if (!quoted) {
    return sb.toString();
  }
  for (int i = 0; i < sb.length(); i++) {
    if (sb.charAt(i) == '\n') {
      sb.insert(i + 1, "\"");
      sb.insert(i, "\\n\"+");
      i += 4;
    }
  }
  sb.delete(sb.length() - 3, sb.length());
  sb.insert(0, "\"");
  return sb.toString();
}

代码示例来源:origin: spring-projects/spring-loaded

protected String toStringClass(byte[] classdata, boolean includeBytecode, boolean quoted) {
  OutputStream os = new SimpleOutputStream();
  ClassPrinter.print(new PrintStream(os), classdata, includeBytecode);
  String s = os.toString();
  StringBuffer sb = new StringBuffer(s.replaceAll("\r", ""));
  if (!quoted) {
    return sb.toString();
  }
  for (int i = 0; i < sb.length(); i++) {
    if (sb.charAt(i) == '\n') {
      sb.insert(i + 1, "\"");
      sb.insert(i, "\\n\"+");
      i += 4;
    }
  }
  sb.insert(0, "\"");
  sb.delete(sb.length() - 3, sb.length());
  return sb.toString();
}

相关文章