public static String stringTo8859_1(String str) throws UnsupportedEncodingException {
  if (str == null) {
    return "";
  }
  return new String(str.getBytes("UTF8"),"8859_1");
}

public static String stringTo8859_1 ( String str ) throws UnsupportedEncodingException { if ( str == null ) { return "" ; } return new String ( str . getBytes ( "UTF8" ) , "8859_1" ) ; }
used to convert username - value , passwd or realm to 8859_1 encoding if all chars in string are within the 8859_1 ( latin 1 ) encoding range .
