List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:com.adaptris.util.stream.Slf4jLoggingOutputStreamTest.java
@Test public void testLogGreaterThanBuffer() throws Exception { PrintStream out = new PrintStream(new Slf4jLoggingOutputStream(LogLevel.INFO)); StringBuffer sb = new StringBuffer(); while (sb.length() < 2048) { sb.append(TEXT);/* w w w .java 2s .c o m*/ } out.println(sb.toString()); out.flush(); out.close(); }
From source file:cn.remex.core.util.StringUtils.java
/** * /* ww w. ja va2 s. co m*/ * Trim leading and trailing whitespace from the given String. * @param str the String to check * @return the trimmed String ?? * @see java.lang.Character#isWhitespace */ public static String trimWhitespace(final String str) { if (!hasLength(str)) { return str; } StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0))) { buf.deleteCharAt(0); } while (buf.length() > 0 && Character.isWhitespace(buf.charAt(buf.length() - 1))) { buf.deleteCharAt(buf.length() - 1); } return buf.toString(); }
From source file:de.bermuda.arquillian.example.ContentTypeProxyTest.java
@Test public void checkBodyTest() { String content = "TestContent"; PostMethod postMethod = postRequest(content); StringBuffer body = getHTTPBody(postMethod); Assert.assertTrue("HTTP Body is empty", body.length() > 0); String returnedContent = body.substring(body.indexOf("<content>") + 9, body.indexOf("</content>")); Assert.assertEquals("Body was not copied", content, returnedContent); }
From source file:de.bermuda.arquillian.example.ContentTypeProxyTest.java
@Test public void checkURLTest() { String localPath = "/foo/bar"; PostMethod postMethod = postRequest("TestContent", localPath); StringBuffer body = getHTTPBody(postMethod); Assert.assertTrue("HTTP Body is empty", body.length() > 0); String returnedPath = body.substring(body.indexOf("<path>") + 6, body.indexOf("</path>")); Assert.assertEquals("Path was not correctly mirrored", localPath, returnedPath); }
From source file:com.amazonaws.services.dynamodbv2.xspec.Path.java
@Override String asSubstituted(SubstitutionContext context) { StringBuffer sb = new StringBuffer(); for (PathElement e : elements) { if (sb.length() == 0) sb.append(e.asToken(context)); else {/* w w w . j a v a 2 s. c o m*/ sb.append(e.asNestedToken(context)); } } return sb.toString(); }
From source file:com.amazonaws.services.dynamodbv2.xspec.Path.java
@Override public String toString() { StringBuffer sb = new StringBuffer(); for (PathElement e : elements) { if (sb.length() == 0) sb.append(e.toString());// w ww. j av a 2 s .c om else { sb.append(e.asNestedPath()); } } return sb.toString(); }
From source file:com.thinkberg.moxo.vfs.s3.S3FileNameParser.java
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { StringBuffer name = new StringBuffer(); String scheme = UriParser.extractScheme(filename, name); UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name);//from w ww . java 2s .com // Normalise the path FileType fileType = UriParser.normalisePath(name); // Extract the root prefix final String bucketName = UriParser.extractFirstElement(name); return new S3FileName(scheme, bucketName, name.toString(), fileType); }
From source file:gov.llnl.lc.smt.command.port.SmtPort.java
protected static String getProblemLines(String type, IB_Port[] pArray) { StringBuffer buff = new StringBuffer(); // show the ports with problems if ((pArray != null) && (pArray.length > 0)) { // collect all these ports into bins, organized by port guids BinList<IB_Port> pbL = new BinList<IB_Port>(); for (IB_Port p : pArray) { pbL.add(p, p.guid.toColonString()); }// w ww. java2 s .co m // there should be at least one bin int n = pbL.size(); for (int j = 0; j < n; j++) { ArrayList<IB_Port> pL = pbL.getBin(j); IB_Port p0 = pL.get(0); String pDesc = ("guid=" + p0.guid + " desc=" + p0.Description); StringBuffer sbuff = new StringBuffer(); for (IB_Port p : pL) sbuff.append(p.portNumber + ", "); // strip off the trailing sbuff.setLength((sbuff.length() - 2)); String pNum = sbuff.toString(); buff.append(getAbbreviatedType(type) + "--" + pDesc + SmtConstants.NEW_LINE); buff.append("port(s)=" + pNum + SmtConstants.NEW_LINE); } } return buff.toString(); }
From source file:org.dataconservancy.dcs.integration.main.IngestTest.java
private String pad(String s, int length, char pad) { StringBuffer buffer = new StringBuffer(s); while (buffer.length() < length) { buffer.insert(0, pad);//from w ww . j ava2s. com } return buffer.toString(); }
From source file:com.hypersocket.network.NetworkResource.java
public String getProtocolsDesc() { StringBuffer buf = new StringBuffer(); for (NetworkProtocol protocol : protocols) { if (buf.length() > 0) { buf.append(","); }/*from ww w .j av a 2 s .c o m*/ buf.append(protocol.getName()); } return buf.toString(); }