Search in sources :

Example 16 with StringBuilder

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());
}
Also used : StringBuilder(java.lang.StringBuilder)

Example 17 with StringBuilder

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"));
}
Also used : StringBuilder(java.lang.StringBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 18 with StringBuilder

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);
}
Also used : StringBuilder(java.lang.StringBuilder)

Example 19 with StringBuilder

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();
}
Also used : StringBuilder(java.lang.StringBuilder) Override(java.lang.Override)

Example 20 with StringBuilder

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();
}
Also used : StringBuilder(java.lang.StringBuilder) Override(java.lang.Override)

Aggregations

StringBuilder (java.lang.StringBuilder)40 Override (java.lang.Override)9 String (java.lang.String)6 IOException (java.io.IOException)5 BufferedReader (java.io.BufferedReader)4 BufferedWriter (java.io.BufferedWriter)2 File (java.io.File)2 NumberFormatException (java.lang.NumberFormatException)2 Object (java.lang.Object)2 ArrayList (java.util.ArrayList)2 Chromosome (PedigreeSim.Chromosome)1 Individual (PedigreeSim.Individual)1 Locus (PedigreeSim.Locus)1 Rational (android.util.Rational)1 Digest (cz1.gbs.core.Digest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 RuntimeException (java.lang.RuntimeException)1