@Override protected byte[] doDecoding(byte[] bytes) throws DecoderException { if (bytes == null) { return null; } boolean hasUnderscores = false; for (byte b : bytes) { if (b == UNDERSCORE) { hasUnderscores = true; break; } } if (hasUnderscores) { byte[] tmp = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; if (b != UNDERSCORE) { tmp[i] = b; } else { tmp[i] = BLANK; } } return QuotedPrintableCodec.decodeQuotedPrintable(tmp); } return QuotedPrintableCodec.decodeQuotedPrintable(bytes); }
public void propertyValues(Collection<String> values) { curPropNode.propValue_vector = values; curPropNode.propValue = listToString(values); // decode value string to propValue_byts if (curPropNode.paraMap.containsKey("ENCODING")) { if (curPropNode.paraMap.getAsString("ENCODING").equalsIgnoreCase("BASE64")) { curPropNode.propValue_byts = Base64.decodeBase64( curPropNode .propValue .replaceAll(" ", "") .replaceAll("\t", "") .replaceAll("\r\n", "") .getBytes()); } if (curPropNode.paraMap.getAsString("ENCODING").equalsIgnoreCase("QUOTED-PRINTABLE")) { try { curPropNode.propValue_byts = QuotedPrintableCodec.decodeQuotedPrintable( curPropNode.propValue.replaceAll("= ", " ").replaceAll("=\t", "\t").getBytes()); curPropNode.propValue = new String(curPropNode.propValue_byts); } catch (Exception e) { System.out.println("=Decode quoted-printable exception."); e.printStackTrace(); } } } curVNode.propList.add(curPropNode); }