Code example for ByteArrayOutputStream

Methods: sizetoByteArray

0
                                  int expectedSignum)
    throws IOException { 
    ImmutableBytesWritable.Comparator comparator =
      new ImmutableBytesWritable.Comparator(); 
 
    ByteArrayOutputStream baosA = new ByteArrayOutputStream();
    ByteArrayOutputStream baosB = new ByteArrayOutputStream();
 
    a.write(new DataOutputStream(baosA));
    b.write(new DataOutputStream(baosB));
 
    assertEquals(
      "Comparing " + a + " and " + b + " as raw",
      signum(comparator.compare(baosA.toByteArray(), 0, baosA.size(),
                                baosB.toByteArray(), 0, baosB.size())),
      expectedSignum);
 
    assertEquals(
      "Comparing " + a + " and " + b + " as raw (inverse)",
      -signum(comparator.compare(baosB.toByteArray(), 0, baosB.size(),
                                 baosA.toByteArray(), 0, baosA.size())),
      expectedSignum);
  } 
 
  private void doComparisonsOnObjects(ImmutableBytesWritable a,
                                      ImmutableBytesWritable b,
Contextual code suggestions in your IDE  Get Codota for Java