List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
public static String fiterHtmlTag(String str, String tag) { String regxp = "<\\s*" + tag + "\\s+([^>]*)\\s*>"; Pattern pattern = Pattern.compile(regxp); Matcher matcher = pattern.matcher(str); StringBuffer sb = new StringBuffer(); boolean result1 = matcher.find(); while (result1) { matcher.appendReplacement(sb, ""); result1 = matcher.find();//from ww w . j av a 2 s . c om } matcher.appendTail(sb); return sb.toString(); }
From source file:Main.java
public static Document domObject(StringBuffer data) throws SAXException, IOException, ParserConfigurationException { Document xmlDoc = null;/*from w ww . j av a 2s. c o m*/ xmlDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(data.toString().getBytes())); return xmlDoc; }
From source file:gov.nyc.doitt.gis.geoclient.parser.regex.PatternUtils.java
public static String literalMatchGroup(Collection<String> strings) { Assert.notEmpty(strings, "Collection of strings argument cannot be empty or null"); StringBuffer buff = new StringBuffer("("); for (String s : strings) { buff.append(s);// w w w . ja va 2 s . c om buff.append("|"); } buff.deleteCharAt(buff.lastIndexOf("|")); buff.append(")"); return buff.toString(); }
From source file:com.huguesjohnson.retroleague.util.RestInvoke.java
public static String invoke(String restUrl) throws Exception { String result = null;/*w w w . j av a 2 s . c o m*/ HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(restUrl); HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); if (httpEntity != null) { InputStream in = httpEntity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuffer temp = new StringBuffer(); String currentLine = null; while ((currentLine = reader.readLine()) != null) { temp.append(currentLine); } result = temp.toString(); in.close(); } return (result); }
From source file:com.salesmanager.core.util.ReferenceUtil.java
public static String buildCatalogUri(MerchantStore store) { StringBuffer chk = new StringBuffer(); chk.append(getUnSecureDomain(store)).append((String) conf.getString("core.salesmanager.catalog.url")); return chk.toString(); }
From source file:Main.java
/** * Can be used to encode values that contain invalid XML characters. * At SAX parser end must be used pair method to get original value. * * @param val data to be converted//from www . jav a 2 s . c o m * @param start offset * @param len count * * @since 1.29 */ public static String toHex(byte[] val, int start, int len) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < len; i++) { byte b = val[start + i]; buf.append(DEC2HEX[(b & 0xf0) >> 4]); buf.append(DEC2HEX[b & 0x0f]); } return buf.toString(); }
From source file:Main.java
private static String toHexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16)); sb.append(Character.forDigit(bytes[i] & 0X0F, 16)); }//from www .j a va 2 s. c o m return sb.toString(); }
From source file:Main.java
protected static String encodeConstraintsNode(Node constraintsNode) { StringBuffer encoded = new StringBuffer(); NodeList constraints = constraintsNode.getChildNodes(); for (int i = 0; i < constraints.getLength(); i++) { encoded.append(constraints.item(i)); }//from w ww .ja v a2 s.co m return encoded.toString(); }
From source file:MainClass.java
/** * Return length many bytes of the passed in byte array as a hex string. * //from www .ja va2s. c om * @param data the bytes to be converted. * @param length the number of bytes in the data block to be converted. * @return a hex representation of length bytes of data. */ public static String toHex(byte[] data, int length) { StringBuffer buf = new StringBuffer(); for (int i = 0; i != length; i++) { int v = data[i] & 0xff; buf.append(digits.charAt(v >> 4)); buf.append(digits.charAt(v & 0xf)); } return buf.toString(); }