code: public static String findEncodingFor(Writer w)
      {
          if (w instanceof OutputStreamWriter) {
              String enc = ((OutputStreamWriter) w).getEncoding();
              /* [WSTX-146]: It is important that we normalize this, since
               *  older JDKs return legacy encoding names ("UTF8" instead of
               *  canonical "UTF-8")
               */
              return normalize(enc);
          }
          return null;
      }
docs: Because of legacy encodings used by earlier JDK versions, we
  need to be careful when accessing encoding names via JDK
  classes.