use of java.lang.StringBuilder in project commoncrawl-examples by commoncrawl.
the class TestArcRecordCC method test_getHttpResponse_getEntity.
public void test_getHttpResponse_getEntity() throws Exception {
r.readFrom(this.getPayload1());
assertNotNull(r.getHttpResponse().getEntity());
byte[] buffer = new byte[1000];
r.getHttpResponse().getEntity().getContent().read(buffer, 0, 1000);
StringBuilder s = new StringBuilder();
s.append("<html>\n");
s.append(" <head>\n");
s.append(" <title>This is a web page!</title>\n");
s.append(" </head>\n");
s.append(" <body>\n");
s.append(" <h1>This is some content!</h1>\n");
s.append(" </body>\n");
s.append("</html>");
String v1 = s.toString();
String v2 = new String(buffer, "UTF-8");
assertEquals(v1.trim(), v2.trim());
}
use of java.lang.StringBuilder in project commoncrawl-examples by commoncrawl.
the class TestArcRecordCC method getPayload1.
/*
public static junit.framework.Test suite() {
return new junit.framework.JUnit4TestAdapter(TestArcRecordCC.class);
}
*/
public InputStream getPayload1() throws Exception {
StringBuilder s = new StringBuilder();
s.setLength(0);
s.append("<html>\n");
s.append(" <head>\n");
s.append(" <title>This is a web page!</title>\n");
s.append(" </head>\n");
s.append(" <body>\n");
s.append(" <h1>This is some content!</h1>\n");
s.append(" </body>\n");
s.append("</html>");
String content = s.toString();
s.setLength(0);
s.append("HTTP/1.1 200 OK\r\n");
s.append("Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n");
s.append("Content-Type: text/html; charset=utf-8\r\n");
s.append("\r\n");
s.append(content);
s.insert(0, "http://www.example.com/path/file.php?param=123,456%20789 123.123.123.123 20120235131415 text/html " + (s.length() - 3) + "\n");
return new ByteArrayInputStream(s.toString().getBytes("UTF-8"));
}
use of java.lang.StringBuilder in project codeu_project_2017 by PabloG6.
the class Uuid method toString.
// Compute human-readable representation for Uuids
// Use long internally to avoid negative integers.
private static String toString(Uuid id) {
final StringBuilder build = new StringBuilder();
buildString(id, build);
// index of 1 to skip initial '.'
return build.substring(1);
}
use of java.lang.StringBuilder in project wire by square.
the class Person method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(", name=").append(Internal.sanitize(name));
builder.append(", id=").append(id);
if (email != null)
builder.append(", email=").append(Internal.sanitize(email));
if (!phone.isEmpty())
builder.append(", phone=").append(phone);
return builder.replace(0, 2, "Person{").append('}').toString();
}
use of java.lang.StringBuilder in project wire by square.
the class KeywordJava method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (final_ != null)
builder.append(", final=").append(Internal.sanitize(final_));
builder.append(", public=").append(public_);
if (!package_.isEmpty())
builder.append(", package=").append(package_);
if (!return_.isEmpty())
builder.append(", return=").append(return_);
if (!enums.isEmpty())
builder.append(", enums=").append(enums);
return builder.replace(0, 2, "KeywordJava{").append('}').toString();
}
Aggregations