List of usage examples for org.apache.commons.vfs.provider UriParser appendEncoded
public static void appendEncoded(final StringBuffer buffer, final String unencodedValue, final char[] reserved)
From source file:org.pentaho.s3.vfs.S3FileName.java
/** * append the user credentials// ww w . j a v a 2 s .c o m */ @Override protected void appendCredentials(StringBuffer buffer, boolean addPassword) { String userName = getUserName(); String password = getPassword(); if (addPassword && userName != null && userName.length() != 0) { try { userName = URLEncoder.encode(getUserName(), "UTF-8"); buffer.append(userName); } catch (UnsupportedEncodingException e) { // fall back to the default UriParser.appendEncoded(buffer, userName, USERNAME_RESERVED); } if (password != null && password.length() != 0) { buffer.append(':'); try { password = URLEncoder.encode(getPassword(), "UTF-8"); buffer.append(password); } catch (UnsupportedEncodingException e) { // fall back to the default UriParser.appendEncoded(buffer, password, PASSWORD_RESERVED); } } buffer.append('@'); } }