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

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

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

StringBuffer.deleteCharAt介绍

暂无

代码示例

代码示例来源:origin: alibaba/arthas

public static void print(int number, List<Integer> primeFactors) {
  StringBuffer sb = new StringBuffer(number + "=");
  for (int factor : primeFactors) {
    sb.append(factor).append('*');
  }
  if (sb.charAt(sb.length() - 1) == '*') {
    sb.deleteCharAt(sb.length() - 1);
  }
  System.out.println(sb);
}

代码示例来源:origin: commons-collections/commons-collections

/**
 * Removes a backslash from every pair of backslashes. 
 */
private static String unescape(String s) {
  StringBuffer buf = new StringBuffer(s);
  for (int i = 0; i < buf.length() - 1; i++) {
    char c1 = buf.charAt(i);
    char c2 = buf.charAt(i + 1);
    if (c1 == '\\' && c2 == '\\') {
      buf.deleteCharAt(i);
    }
  }
  return buf.toString();
}

代码示例来源:origin: alibaba/mdrill

public String getNotExcapedValue() {
  StringBuffer buffer = new StringBuffer(value);
  int index = 0;
  int deletesNum = 0;
  while ((index = value.indexOf("''", index)) != -1) {
    buffer.deleteCharAt(index-deletesNum);
    index+=2;
    deletesNum++;
  }
  return buffer.toString();
}

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

/**
 * Removes a backslash from every pair of backslashes. 
 */
private static String unescape(String s) {
  StringBuffer buf = new StringBuffer(s);
  for (int i = 0; i < buf.length() - 1; i++) {
    char c1 = buf.charAt(i);
    char c2 = buf.charAt(i + 1);
    if (c1 == '\\' && c2 == '\\') {
      buf.deleteCharAt(i);
    }
  }
  return buf.toString();
}

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

public static String getPrintableText(List<Candidate> candidates) {
  StringBuffer sb = new StringBuffer();
  sb.append("[");
  for (Candidate candidate : candidates) {
    IRealization r = candidate.realization;
    sb.append(r.getCanonicalName());
    sb.append(",");
  }
  if (sb.charAt(sb.length() - 1) != '[')
    sb.deleteCharAt(sb.length() - 1);
  sb.append("]");
  return sb.toString();
}

代码示例来源:origin: signalapp/Signal-Server

public static String encodeFormParams(Map<String, String> params) {
 try {
  StringBuffer buffer = new StringBuffer();
  for (String key : params.keySet()) {
   buffer.append(String.format("%s=%s",
                 URLEncoder.encode(key, "UTF-8"),
                 URLEncoder.encode(params.get(key), "UTF-8")));
   buffer.append("&");
  }
  buffer.deleteCharAt(buffer.length()-1);
  return buffer.toString();
 } catch (UnsupportedEncodingException e) {
  throw new AssertionError(e);
 }
}

代码示例来源:origin: org.osgi/org.osgi.compendium

/**
 * Decode the node name so that back slash and forward slash are un-escaped
 * from a back slash.
 * 
 * @param nodeName the node name to be decoded
 * @return the decoded node name
 * @since 2.0
 */
public static String decode(String nodeName) {
  // Try not to create an object when it is not necessary
  int n = nodeName.indexOf('\\');
  if (n < 0)
    return nodeName;
  StringBuffer sb = new StringBuffer(nodeName);
  while (n >= 0 && n < sb.length()) {
    sb.deleteCharAt(n);
    n++;
    while (n < sb.length() && sb.charAt(n) != '\\')
      n++;
  }
  return sb.toString();
}

代码示例来源:origin: knightliao/disconf

/**
 * @param pathElements
 *
 * @return boolean
 *
 * @throws Exception
 * @Description: JOIN PATH
 * @author liaoqiqi
 * @date 2013-6-13
 */
public static String pathJoin(final String... pathElements) {
  final String path;
  if (pathElements == null || pathElements.length == 0) {
    path = File.separator;
  } else {
    final StringBuffer sb = new StringBuffer();
    for (final String pathElement : pathElements) {
      if (pathElement.length() > 0) {
        sb.append(pathElement);
        sb.append(File.separator);
      }
    }
    if (sb.length() > 0) {
      sb.deleteCharAt(sb.length() - 1);
    }
    path = sb.toString();
  }
  return (path);
}

代码示例来源:origin: jmdhappy/xxpay-master

/**
 * 将字符串"元"转换成"分"
 * @param str
 * @return
 */
public static String convertDollar2Cent(String str) {
  DecimalFormat df = new DecimalFormat("0.00");
  StringBuffer sb = df.format(Double.parseDouble(str),
      new StringBuffer(), new FieldPosition(0));
  int idx = sb.toString().indexOf(".");
  sb.deleteCharAt(idx);
  for (; sb.length() != 1;) {
    if(sb.charAt(0) == '0') {
      sb.deleteCharAt(0);
    } else {
      break;
    }
  }
  return sb.toString();
}

代码示例来源:origin: Dreampie/Resty

public String getNextWord() {
 Random rnd = new Random();
 StringBuffer sb = new StringBuffer();
 StringBuffer chars = new StringBuffer(characters);
 int l = minLength + (maxLength > minLength ? rnd.nextInt(maxLength - minLength) : 0);
 for (int i = 0; i < l; i++) {
  int j = rnd.nextInt(chars.length());
  char c = chars.charAt(j);
  if (wideCharacters.indexOf(c) != -1) {
   for (int k = 0; k < wideCharacters.length(); k++) {
    int idx = chars.indexOf(String.valueOf(wideCharacters.charAt(k)));
    if (idx != -1) {
     chars.deleteCharAt(idx);
    }
   }
  }
  sb.append(c);
 }
 return sb.toString();
}

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

/**
 * Converts the shape flags into a more descriptive name.
 */
private String decodeFlags( int flags )
{
  StringBuffer result = new StringBuffer();
  result.append( ( flags & FLAG_GROUP ) != 0 ? "|GROUP" : "" );
  result.append( ( flags & FLAG_CHILD ) != 0 ? "|CHILD" : "" );
  result.append( ( flags & FLAG_PATRIARCH ) != 0 ? "|PATRIARCH" : "" );
  result.append( ( flags & FLAG_DELETED ) != 0 ? "|DELETED" : "" );
  result.append( ( flags & FLAG_OLESHAPE ) != 0 ? "|OLESHAPE" : "" );
  result.append( ( flags & FLAG_HAVEMASTER ) != 0 ? "|HAVEMASTER" : "" );
  result.append( ( flags & FLAG_FLIPHORIZ ) != 0 ? "|FLIPHORIZ" : "" );
  result.append( ( flags & FLAG_FLIPVERT ) != 0 ? "|FLIPVERT" : "" );
  result.append( ( flags & FLAG_CONNECTOR ) != 0 ? "|CONNECTOR" : "" );
  result.append( ( flags & FLAG_HAVEANCHOR ) != 0 ? "|HAVEANCHOR" : "" );
  result.append( ( flags & FLAG_BACKGROUND ) != 0 ? "|BACKGROUND" : "" );
  result.append( ( flags & FLAG_HASSHAPETYPE ) != 0 ? "|HASSHAPETYPE" : "" );
  //need to check, else blows up on some records - bug 34435
  if(result.length() > 0) {
    result.deleteCharAt(0);
  }
  return result.toString();
}

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

private void innerAddParametrizedClassToMapping(final ASTFieldDeclaration node, final ClassTypeRef innerClassRef) {
  List<Identifier> ids = innerClassRef.getNames();
  StringBuffer argType = new StringBuffer();
  for (Identifier id : ids) {
    argType.append(id.getValue()).append(".");
  }
  argType.deleteCharAt(argType.length() - 1);
  addVariableToMapping(Helper.getFQVariableName(node), argType.toString());
}

代码示例来源:origin: org.osgi/org.osgi.compendium

newsegment.deleteCharAt(i); // remove the extra '\'
} else
  if (newsegment.charAt(i) == '/')

代码示例来源:origin: internetarchive/heritrix3

/**
  Creates a URIToFileReturn.
  @param baseDir the path to the starting directory
  @param host the host part of the URI, or null if the host name
  should not be part of the path
  @param port the port part of the URI, or -1 if the port
  should not be part of the path
*/
URIToFileReturn(String baseDir, String host, int port) {
  // The initial path.
  StringBuffer startPath = new StringBuffer(baseDir.length() + 32);
  startPath.append(baseDir);
  if (baseDir.endsWith(File.separator)) {
    assert 1 != baseDir.length();
    startPath.deleteCharAt(startPath.length() - 1);
  }
  if (null != host) {
    startPath.append(File.separatorChar);
    startPath.append(host);
    relativePath.append(host);
  }
  if (port > 0) {
    startPath.append(File.separatorChar);
    startPath.append(port);
    relativePath.append(File.separatorChar);
    relativePath.append(port);
  }
  filePath = new File(startPath.toString());
}

代码示例来源:origin: knightliao/disconf

/**
 * 获取 配置项 或者 是配置ITEM 的远程URL
 *
 * @return
 */
public static String getRemoteUrlParameter(String urlPrefix, String app, String version, String env, String key,
                      DisConfigTypeEnum disConfigTypeEnum) {
  Map<String, String> parameterMap = getConfServerBasePathMap(app, version, env, key);
  // 配置文件或配置项
  parameterMap.put(Constants.TYPE, String.valueOf(disConfigTypeEnum.getType()));
  StringBuffer sb = new StringBuffer();
  sb.append(urlPrefix);
  if (disConfigTypeEnum.getType() == DisConfigTypeEnum.FILE.getType()) {
    sb.append(Constants.SEP_STRING + Constants.STORE_FILE_URL_KEY);
  } else {
    sb.append(Constants.SEP_STRING + Constants.STORE_ITEM_URL_KEY);
  }
  sb.append("?");
  for (String thisKey : parameterMap.keySet()) {
    String cur = thisKey + "=" + parameterMap.get(thisKey);
    cur += "&";
    sb.append(cur);
  }
  if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1);
  }
  return sb.toString();
}

代码示例来源:origin: osmandapp/Osmand

snorthing.deleteCharAt(0);

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

wildcardPosition = -1; // escape the wildcard
buffer.deleteCharAt(i); // one \ escapes next
len--;

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

/**
 * analyzes the error information, and converts it into a Javascript object  string, which can be passed to to the HTML form through the entityForm
 * @param result
 * @return
 */
private String resultToJS(BindingResult result) {
  StringBuffer sb = new StringBuffer("[");
  List<ObjectError> errors = result.getAllErrors();
  for (ObjectError objectError : errors) {
    if (objectError instanceof FieldError) {
      FieldError ferr = (FieldError) objectError;
      sb.append("{");
      String fieldOnly = StringUtil.extractFieldNameFromExpression(ferr.getField());
      sb.append("\"").append(fieldOnly).append("\":");
      String localizedMessage = BLCMessageUtils.getMessage(ferr.getDefaultMessage());
      sb.append("\"").append(localizedMessage).append("\"");
      sb.append("},");
    }
  }
  if (sb.length() > 1) {
    sb.deleteCharAt(sb.length() - 1); //the last comma
  }
  sb.append("]");
  return sb.toString();
}

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

if (unicodeBuf.length() > 0) {
  ch = (int) unicodeBuf.charAt(0);
  unicodeBuf.deleteCharAt(0);
} else {
  ch = in.read();

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

@Override
public Object visit(final ASTFieldDeclaration node, Object data) {
  ASTFieldDeclarationStatements field = node.getFirstParentOfType(ASTFieldDeclarationStatements.class);
  if (field != null) {
    TypeRef a = field.getNode().getTypeName();
    List<Identifier> names = a.getNames();
    List<TypeRef> typeArgs = a.getTypeArguments();
    if (!names.isEmpty()) {
      StringBuffer sb = new StringBuffer();
      for (Identifier id : names) {
        sb.append(id.getValue()).append(".");
      }
      sb.deleteCharAt(sb.length() - 1);
      switch (sb.toString().toLowerCase(Locale.ROOT)) {
      case "list":
      case "map":
        addParametersToMapping(node, typeArgs);
        break;
      default:
        varToTypeMapping.put(Helper.getFQVariableName(node), getSimpleType(sb.toString()));
        break;
      }
    }
  }
  final ASTSoqlExpression soql = node.getFirstChildOfType(ASTSoqlExpression.class);
  if (soql != null) {
    checkForAccessibility(soql, data);
  }
  return data;
}

相关文章