List of usage examples for java.lang StringBuffer deleteCharAt
@Override public synchronized StringBuffer deleteCharAt(int index)
From source file:FillViewportHeightDemo.java
private static String getNextString(int count) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < 5; i++) { buf.append(String.valueOf(count)); buf.append(","); }/*w w w . j av a2 s. c om*/ // remove last newline buf.deleteCharAt(buf.length() - 1); return buf.toString(); }
From source file:org.exoplatform.wiki.rendering.internal.parser.confluence.ConfluenceLinkReferenceParser.java
public static String divideOn(StringBuffer buffer, char divider) { if (buffer.length() == 0) { return null; }/*from ww w .j a v a 2 s .co m*/ int i = buffer.indexOf(Character.toString(divider)); if (i < 0) { return null; } if (i == 0) { buffer.deleteCharAt(0); return null; } String body = buffer.substring(0, i); buffer.delete(0, i + 1); return body; }
From source file:org.talend.repository.hadoopcluster.util.HCVersionUtil.java
public static void injectCustomVersionMap(HadoopClusterConnection connection, Map<String, Set<String>> map) { if (connection == null || map == null) { return;//from w ww. ja va 2 s.c o m } EMap<String, String> parameters = connection.getParameters(); // remove previous custom param for (String group : map.keySet()) { if (parameters.keySet().contains(group)) { parameters.put(group, EMPTY_STR); } } Iterator<Entry<String, Set<String>>> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, Set<String>> entry = iter.next(); String groupName = entry.getKey(); Set<String> jars = entry.getValue(); if (jars != null && jars.size() > 0) { StringBuffer jarBuffer = new StringBuffer(); for (String jar : jars) { jarBuffer.append(jar).append(JAR_SEPARATOR); } if (jarBuffer.length() > 0) { jarBuffer.deleteCharAt(jarBuffer.length() - 1); parameters.put(groupName, jarBuffer.toString()); } } } }
From source file:org.talend.core.hadoop.version.custom.HadoopVersionControlUtils.java
public static void injectCustomVersionMap(DatabaseConnection connection, Map<String, Set<String>> map, ECustomVersionGroup group) {/* ww w.j a va 2 s . com*/ if (connection == null || map == null || group == null) { return; } EMap<String, String> parameters = connection.getParameters(); StringBuffer jarBuffer = new StringBuffer(); Set<String> jars = map.get(group.getName()); if (jars != null) { for (String jar : jars) { jarBuffer.append(jar).append(JAR_SEPARATOR); } if (jarBuffer.length() > 0) { jarBuffer.deleteCharAt(jarBuffer.length() - 1); } } parameters.put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CUSTOM_JARS, jarBuffer.toString()); }
From source file:chen.android.toolkit.network.HttpConnection.java
/** * </br><b>title : </b> ????POST?? * </br><b>description :</b>????POST?? * </br><b>time :</b> 2012-7-8 ?4:33:20 * @param url POSTURL/* w w w. j ava 2 s . c om*/ * @param params POST? * @param data ???? * @return ??? * @throws MalformedURLException * @throws IOException */ public static InputStream post(String url, Map<String, String> params, byte[] data) throws MalformedURLException, IOException { StringBuffer sb = new StringBuffer(); for (Map.Entry<String, String> entry : params.entrySet()) { sb.append(entry.getKey()).append("=").append(entry.getValue()); sb.append("&"); } String param = sb.deleteCharAt(sb.length() - 1).toString(); return connect("POST", new URL(url), param.getBytes(), data); }
From source file:chen.android.toolkit.network.HttpConnection.java
/** * </br><b>title : </b> ????GET?? * </br><b>description :</b>????GET?? * </br><b>time :</b> 2012-7-8 ?4:35:23 * @param url GETURL/*from w w w .j a v a 2s. c o m*/ * @param params ???? * @return ??? * @throws MalformedURLException * @throws IOException */ public static InputStream get(String url, Map<String, String> params) throws MalformedURLException, IOException { StringBuffer sb = new StringBuffer(); for (Map.Entry<String, String> entry : params.entrySet()) { sb.append(entry.getKey()).append("=").append(entry.getValue()); sb.append("&"); } String param = sb.deleteCharAt(sb.length() - 1).toString(); return connect("GET", new URL(url), param.getBytes()); }
From source file:org.ops4j.pax.web.service.internal.WelcomeFilesFilter.java
private static String addPaths(final String path1, final String path2) { if (path1 == null || path1.length() == 0) { if (path1 != null && path2 == null) { return path1; }/* w w w .j a v a2 s.co m*/ return path2; } if (path2 == null || path2.length() == 0) { return path1; } int split = path1.indexOf(';'); if (split < 0) { split = path1.indexOf('?'); } if (split == 0) { return path2 + path1; } if (split < 0) { split = path1.length(); } StringBuffer buf = new StringBuffer(path1.length() + path2.length() + 2); buf.append(path1); if (buf.charAt(split - 1) == '/') { if (path2.startsWith("/")) { buf.deleteCharAt(split - 1); buf.insert(split - 1, path2); } else { buf.insert(split, path2); } } else { if (path2.startsWith("/")) { buf.insert(split, path2); } else { buf.insert(split, '/'); buf.insert(split + 1, path2); } } return buf.toString(); }
From source file:Main.java
private static String removeUnecessaryIndent(String docs) { int count = 0; String[] lines = docs.split("\n"); if (lines == null || lines.length == 0) return docs; String tmp = lines[0];/*from w w w . j ava 2 s . co m*/ if (tmp != null && tmp.length() > 0) { while (tmp.charAt(0) == ' ') { count++; if (tmp.length() == 1) break; tmp = tmp.substring(1); } } StringBuffer modified = new StringBuffer(); for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (line.length() > count) { if (line.substring(0, count).trim().length() == 0) { line = line.substring(count); } } modified.append(line); modified.append("\n"); } modified.deleteCharAt(modified.length() - 1); // remove last newline return modified.toString(); }
From source file:org.snaker.modules.base.helper.SnakerJsonHelper.java
public static String getActiveJson(List<Task> tasks) { StringBuffer buffer = new StringBuffer(); buffer.append("{'activeRects':{'rects':["); for (Task task : tasks) { buffer.append("{'paths':[],'name':'"); buffer.append(task.getDisplayName()); buffer.append("'},"); }//from w w w . j a va2 s . c om buffer.deleteCharAt(buffer.length() - 1); buffer.append("]}}"); buffer.append(""); buffer.append(""); return buffer.toString(); }
From source file:com.apkits.android.network.HttpConnection.java
/** * </br><b>title : </b> ????GET?? * </br><b>description :</b>????GET?? * </br><b>time :</b> 2012-7-8 ?4:35:23 * @param url GETURL//from w w w.jav a 2 s .c o m * @param params ???? * @return ??? * @throws MalformedURLException * @throws IOException */ public static InputStream get(String url, Map<String, String> params) throws MalformedURLException, IOException { if (null != params) { StringBuffer sb = new StringBuffer(); for (Map.Entry<String, String> entry : params.entrySet()) { sb.append(entry.getKey()).append("=").append(entry.getValue()); sb.append("&"); } String param = sb.deleteCharAt(sb.length() - 1).toString(); return connect("GET", new URL(url), param.getBytes()); } return connect("GET", new URL(url), new byte[] {}); }