本文整理汇总了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();
}
}