public static PrintWriter printWriterFor(Writer writer) {
    if (writer instanceof PrintWriter) {
      return (PrintWriter) writer;
    }

    return new PrintWriter(writer);
  }
Makes a {@code PrintWriter} for the given {@code Writer}, returning the given writer if it
already happens to be the right class.

@param writer {@code non-null;} writer to (possibly) wrap
@return {@code non-null;} an appropriate instance
android/android_framework/dex-maker/src/main/java/com/android/dx/util/Writers.java