本文整理汇总了Java中java.io.UnsupportedEncodingException.toString方法的典型用法代码示例。如果您正苦于以下问题:Java UnsupportedEncodingException.toString方法的具体用法?Java UnsupportedEncodingException.toString怎么用?Java UnsupportedEncodingException.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.UnsupportedEncodingException
的用法示例。
在下文中一共展示了UnsupportedEncodingException.toString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CertificateHolderReference
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
CertificateHolderReference(byte[] contents)
{
try
{
String concat = new String(contents, ReferenceEncoding);
this.countryCode = concat.substring(0, 2);
this.holderMnemonic = concat.substring(2, concat.length() - 5);
this.sequenceNumber = concat.substring(concat.length() - 5);
}
catch (UnsupportedEncodingException e)
{
throw new IllegalStateException(e.toString());
}
}
示例2: digestString
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
/**
* Retrieves a byte sequence representing the MD5 digest of the
* specified character sequence, using the specified encoding to
* first convert the character sequence into a byte sequence.
* If the specified encoding is null, then ISO-8859-1 is
* assumed.
*
* @param string the string to digest.
* @param encoding the character encoding.
* @return the digest as an array of 16 bytes.
* @throws HsqlUnsupportedOperationException if an MD5 digest
* algorithm is not available through the
* java.security.MessageDigest spi or the requested
* encoding is not available
*/
public static byte[] digestString(String string,
String encoding)
throws RuntimeException {
byte[] data;
if (encoding == null) {
encoding = "ISO-8859-1";
}
try {
data = string.getBytes(encoding);
} catch (UnsupportedEncodingException x) {
throw new RuntimeException(x.toString());
}
return digestBytes(data);
}
示例3: getName
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
public String getName(){
if(name==null) return "";
try {
return new String(name, "ISO-8859-1");
}
catch (UnsupportedEncodingException e) {
throw new InternalError(e.toString());
}
}
示例4: getComment
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
public String getComment(){
if(comment==null) return "";
try {
return new String(comment, "ISO-8859-1");
}
catch (UnsupportedEncodingException e) {
throw new InternalError(e.toString());
}
}
示例5: getEncoded
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
public byte[] getEncoded()
{
String ref = countryCode + holderMnemonic + sequenceNumber;
try
{
return ref.getBytes(ReferenceEncoding);
}
catch (UnsupportedEncodingException e)
{
throw new IllegalStateException(e.toString());
}
}
示例6: toBytes
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
public static byte[] toBytes(String s) {
try {
return s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.toString(), e);
}
}
示例7: toString
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
public static String toString(byte[] bytes) {
try {
return new String(bytes, "UTF-8").trim();
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.toString(), e);
}
}
示例8: toString
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
@Override
public String toString() {
try {
StringBuilder result = new StringBuilder();
boolean first = true;
if (values.length == 0) {
return URLEncoder.encode(name, "UTF-8");
}
for (String value : values) {
if (first) {
first = false;
} else {
result.append('&');
}
if (name != null) {
result.append(URLEncoder.encode(name, "UTF-8"));
}
if (value != null) {
result.append('=');
result.append(URLEncoder.encode(value, "UTF-8"));
}
}
return result.toString();
} catch (UnsupportedEncodingException ex) {
return ex.toString();
}
}
示例9: writeString
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
final void writeString(String s, String encoding, MySQLConnection conn) throws SQLException {
ensureCapacity((s.length() * 3) + 1);
try {
writeStringNoNull(s, encoding, encoding, false, conn);
} catch (UnsupportedEncodingException ue) {
throw new SQLException(ue.toString(), SQLError.SQL_STATE_GENERAL_ERROR);
}
this.byteBuffer[this.position++] = 0;
}
示例10: ISO2GB
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
/**
* 转换编码 ISO-8859-1到GB2312
* @param text
* @return
*/
public static final String ISO2GB(String text) {
String result = "";
try {
result = new String(text.getBytes("ISO-8859-1"), "GB2312");
}
catch (UnsupportedEncodingException ex) {
result = ex.toString();
}
return result;
}
示例11: getInputStream
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
/**
* Returns the input stream of the XML view.
*
* @return the input stream of the XML view
*/
public InputStream getInputStream() {
// Turn StringBuffer into InputStream
try {
return new ByteArrayInputStream(buf.toString().getBytes("UTF-8"));
} catch (UnsupportedEncodingException uee) {
// should never happen
throw new RuntimeException(uee.toString());
}
}
示例12: OutputBufferThread
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
/**
* Creates a new OutputBufferThread to consume the given InputStream.
*
* @param is InputStream to consume
*/
public OutputBufferThread(InputStream is) {
this.setDaemon(true);
output = new ArrayList<String>();
try {
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Unsupported encoding " + e.toString());
}
}
示例13: decode
import java.io.UnsupportedEncodingException; //导入方法依赖的package包/类
/**
* Decodes a URL safe string into its original form using the
* specified character set. Escaped characters are converted back
* to their original representation.
*
* This method is copied from the <b>Jakarta Commons Codec</b>;
* <code>org.apache.commons.codec.net.URLCodec</code> class.
*
* @param string URL safe string to convert into its original form
* @return original string
* @throws IllegalArgumentException thrown if URL decoding is unsuccessful,
*/
public static String decode( String string, String charset ) {
try {
if (string == null) return null;
return new String( decodeUrl( string.getBytes( "US-ASCII" ) ), charset );
} catch (UnsupportedEncodingException e) {
throw new RuntimeException( e.toString() );
}
}