本文整理匯總了Java中org.apache.commons.codec.DecoderException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java DecoderException.printStackTrace方法的具體用法?Java DecoderException.printStackTrace怎麽用?Java DecoderException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.codec.DecoderException
的用法示例。
在下文中一共展示了DecoderException.printStackTrace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decode
import org.apache.commons.codec.DecoderException; //導入方法依賴的package包/類
@NonNull
@Override
public String decode(@NonNull String text) {
setMax(1);
setConfident(1);
org.apache.commons.codec.net.URLCodec urlCodec = new org.apache.commons.codec.net.URLCodec();
try {
return urlCodec.decode(text);
} catch (DecoderException e) {
setConfident(0);
e.printStackTrace();
return text;
}
}
示例2: hex2Binary
import org.apache.commons.codec.DecoderException; //導入方法依賴的package包/類
/**
* Convert a Hex string to Binary. It uses org.apache.commons.codec.binary.Hex.decodeHex(char[])
*
* @param hexString Hex string to convert
* @return Binary bytes
* <p>
* @author [email protected] - Sep 9, 2017
*/
public static byte[] hex2Binary(String hexString)
{
byte[] data = null;
try
{
data = Hex.decodeHex(hexString.toCharArray());
} catch (DecoderException e)
{
e.printStackTrace();
logger.error("Exception caught: " + e.getLocalizedMessage());
return null;
}
return data;
}
示例3: decode
import org.apache.commons.codec.DecoderException; //導入方法依賴的package包/類
public String decode(String valueEncoded) {
StringBuilder builder = new StringBuilder();
Matcher m = decodePattern.matcher(valueEncoded);
int prevEnd = 0;
while (m.find()) {
try {
int start = m.start();
int end = m.end();
String sub = valueEncoded.substring(start, end).replaceAll(delimiter, "");
String decoded = new String(Hex.decodeHex(sub.toCharArray()), StandardCharsets.UTF_8);
builder.append(valueEncoded.substring(prevEnd, start));
builder.append(decoded);
prevEnd = end - 1;
} catch (DecoderException e) {
e.printStackTrace();
}
}
prevEnd++;
if (prevEnd < valueEncoded.length()) {
builder.append(valueEncoded.substring(prevEnd, valueEncoded.length()));
}
if (builder.length() == 0) {
return valueEncoded;
} else {
return builder.toString();
}
}