List of usage examples for java.lang StringBuilder delete
@Override public StringBuilder delete(int start, int end)
From source file:Main.java
public static String replaceAndEndnote(String text, String holderString, String replacement, String noteTag, String noteSplit) {/* w w w. jav a 2 s .c o m*/ StringBuilder note = new StringBuilder(); note.append(noteTag); String tmp = new String(text); int start = 0; while ((start = tmp.indexOf(holderString, start)) >= 0) { note.append(start + noteSplit); start += holderString.length(); } start = note.length() - noteSplit.length(); if (note.substring(start).equals(noteSplit)) note.delete(start, note.length()); return text.replace(holderString, replacement) + note; }
From source file:net.certiv.json.util.Strings.java
public static String csvList(List<String> stringList) { if (stringList == null) return ""; StringBuilder sb = new StringBuilder(); for (String str : stringList) { sb.append(str + ", "); }//from ww w .j ava 2 s.c om int len = sb.length(); sb.delete(len - 2, len); return sb.toString(); }
From source file:com.abstratt.mdd.frontend.textuml.renderer.TextUMLRenderingUtils.java
public static void renderStereotypeApplications(PrintWriter writer, NamedElement element, boolean newLine) { List<EObject> applications = element.getStereotypeApplications(); if (applications.isEmpty()) return;//from w w w. j a v a 2s . c o m StringBuilder builder = new StringBuilder(); builder.append("["); for (EObject application : applications) { renderStereotypeApplication(element, builder, application); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); builder.append("]"); writer.print(builder); if (newLine) writer.println(); else writer.print(' '); }
From source file:com.example.mobilewebproxy.MainActivity.java
private static Double getApproxValue(Double val) { int index;/*from ww w .j a v a 2 s . co m*/ final String delim = "."; final String stringValue = val.toString(); StringBuilder builder = new StringBuilder(stringValue); index = stringValue.indexOf(delim); if (index != -1) builder.delete(index + 2, builder.length()); return Double.parseDouble(builder.toString()); }
From source file:com.gallatinsystems.survey.dao.SurveyUtils.java
/** * Given the path of an object, return a list of the paths of all its parent objects * * @param objectPath the path of an object * @param includeRootPath include the root path in the list of parent paths * @return/*from ww w. j a va 2s .co m*/ */ public static List<String> listParentPaths(String objectPath, boolean includeRootPath) { List<String> parentPaths = new ArrayList<String>(); StringBuilder path = new StringBuilder(objectPath); while (path.length() > 1) { path.delete(path.lastIndexOf("/"), path.length()); if (StringUtils.isNotBlank(path.toString())) { parentPaths.add(path.toString().trim()); } } if (includeRootPath) { parentPaths.add("/"); } return parentPaths; }
From source file:com.dsh105.nexus.util.StringUtil.java
public static String combineSplit(int startIndex, String[] string, String separator) { if (string == null || startIndex >= string.length) { return ""; } else {//w w w .ja v a 2s. co m StringBuilder builder = new StringBuilder(); for (int i = startIndex; i < string.length; i++) { builder.append(string[i]); builder.append(separator); } builder.delete(builder.length() - separator.length(), builder.length()); return builder.toString(); } }
From source file:com.cinchapi.concourse.lang.Parser.java
/** * This is a helper method for {@link #toPostfixNotation(String)} that * contains the logic to create a ValueSymbol from a buffered value. * //from ww w.ja v a 2 s. c o m * @param buffer * @param symbols */ private static void addBufferedValue(StringBuilder buffer, List<Symbol> symbols) { if (buffer != null && buffer.length() > 0) { buffer.delete(buffer.length() - 1, buffer.length()); symbols.add(ValueSymbol.parse(buffer.toString())); buffer.delete(0, buffer.length()); } }
From source file:com.cinchapi.concourse.lang.Parser.java
private static void addBufferedTime(StringBuilder buffer, List<Symbol> symbols) { if (buffer != null && buffer.length() > 0) { buffer.delete(buffer.length() - 1, buffer.length()); long ts = NaturalLanguage.parseMicros(buffer.toString()); symbols.add(TimestampSymbol.create(ts)); buffer.delete(0, buffer.length()); }/* www .j ava2 s. co m*/ }
From source file:fr.inria.eventcloud.deployment.cli.launchers.EventCloudsManagementServiceDeployer.java
private static String addClassPath(String libsUrl) throws IOException { downloadLibs(libsUrl);/*from www .j av a2s . c om*/ File libDir = new File(libDirPath); String[] libNames = libDir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".jar"); } }); StringBuilder classPath = new StringBuilder(); for (String libName : libNames) { classPath.append(libDirPath).append(File.separator).append(libName).append(File.pathSeparator); } classPath.delete(classPath.length() - 2, classPath.length() - 1); return classPath.toString(); }
From source file:com.qmetry.qaf.automation.ws.rest.RequestLogger.java
public static void deleteAll(StringBuilder builder, String str) { if (null == builder) { return;//w ww. j a v a2 s. c om } int index = builder.indexOf(str); while (index != -1) { builder.delete(index, index + str.length()); index = builder.indexOf(str, index); } }