code: public static String parseCharacterEncoding( final String contentType )
      {
  
          if ( contentType == null )
          {
              return ( null );
          }
          final int start = contentType.indexOf( "charset=" );
          if ( start < 0 )
          {
              return ( null );
          }
          String encoding = contentType.substring( start + 8 );
          final int end = encoding.indexOf( ';' );
          if ( end >= 0 )
          {
              encoding = encoding.substring( 0, end );
          }
          encoding = encoding.trim();
          if ( ( encoding.length() > 2 ) && ( encoding.startsWith( "\"" ) ) && ( encoding.endsWith( "\"" ) ) )
          {
              encoding = encoding.substring( 1, encoding.length() - 1 );
          }
          return ( encoding.trim() );
  
      }
docs: Parse the character encoding from the specified content type header. If
  the content type is null, or there is no explicit character encoding,
  <code>null</code> is returned.
  
  @param contentType
  a content type header