Example usage for org.apache.commons.httpclient URIException UNSUPPORTED_ENCODING

List of usage examples for org.apache.commons.httpclient URIException UNSUPPORTED_ENCODING

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URIException UNSUPPORTED_ENCODING.

Prototype

int UNSUPPORTED_ENCODING

To view the source code for org.apache.commons.httpclient URIException UNSUPPORTED_ENCODING.

Click Source Link

Document

The unsupported character encoding.

Usage

From source file:be.jcdo.mp3searchengines.tools.URIUtils.java

/**
 * Convert a target string from the fromCharset charset to
 * the toCharset charset.//from   ww  w  .  ja  va 2  s  .co  m
 * 
        
 * What if the document charset is ISO-8859-1 and the protocol charset is
 * UTF-8, when it's read from the document part and is used in the protocol
 * part, the use of the method will be toUsingCharset(the string,
 * "ISO-8859-1", "UTF-8").
 *
 * @param target a target string
 * @param fromCharset the previous charset
 * @param toCharset the changing charset
 * @return the document character encoded string
 * 
 * @throws URIException if either of the charsets are not supported
 * 
 * @deprecated Do not use. To be removed
 */

public static String toUsingCharset(String target, String fromCharset, String toCharset) throws URIException {

    try {
        return new String(target.getBytes(fromCharset), toCharset);
    } catch (UnsupportedEncodingException error) {
        throw new URIException(URIException.UNSUPPORTED_ENCODING, error.getMessage());
    }
}