public void writeAnnotationsTo(Writer out) throws IOException {
    int width2 = getAnnotationWidth();
    int width1 = annotationWidth - width2 - 1;

    TwoColumnOutput twoc = new TwoColumnOutput(out, width1, width2, "|");
    Writer left = twoc.getLeft();
    Writer right = twoc.getRight();
    int leftAt = 0; // left-hand byte output cursor
    int rightAt = 0; // right-hand annotation index
    int rightSz = annotations.size();

    while ((leftAt < cursor) && (rightAt < rightSz)) {
      Annotation a = annotations.get(rightAt);
      int start = a.getStart();
      int end;
      String text;

      if (leftAt < start) {
        // This is an area with no annotation.
        end = start;
        start = leftAt;
        text = "";
      } else {
        // This is an area with an annotation.
        end = a.getEnd();
        text = a.getText();
        rightAt++;
      }

      left.write(Hex.dump(data, start, end - start, start, hexCols, 6));
      right.write(text);
      twoc.flush();
      leftAt = end;
    }

    if (leftAt < cursor) {
      // There is unannotated output at the end.
      left.write(Hex.dump(data, leftAt, cursor - leftAt, leftAt, hexCols, 6));
    }

    while (rightAt < rightSz) {
      // There are zero-byte annotations at the end.
      right.write(annotations.get(rightAt).getText());
      rightAt++;
    }

    twoc.flush();
  }
Writes the annotated content of this instance to the given writer.

@param out {@code non-null;} where to write to
android/android_framework/dex-maker/src/main/java/com/android/dx/util/ByteArrayAnnotatedOutput.java