【问题标题】:How to decode the attachment file in [MIME] java mail如何解码 [MIME] java 邮件中的附件文件
【发布时间】:2012-05-21 21:14:07
【问题描述】:

我无法解码附件。它类似于=?utf-8?B?MS5qcGc=,它是编码的。我需要解码那个附件。 我用来解码的java代码

private static String decodeName(String name) throws Exception {
  if (name == null || name.length() == 0) {
   return "unknown";
  }
  String ret = java.net.URLDecoder.decode(name, "UTF-8");

  // also check for a few other things in the string:
  ret = ret.replaceAll("=\\?utf-8\\?q\\?", "");
  ret = ret.replaceAll("\\?=", "");
  ret = ret.replaceAll("=20", " ");

  return ret;
 }

请帮我解码。

【问题讨论】:

    标签: java jakarta-mail mime decode mime-message


    【解决方案1】:

    您正在尝试解码附件名称,对吗?见this JavaMail FAQ entry

    【讨论】:

      猜你喜欢
      • 2011-08-09
      • 2015-05-28
      • 2011-02-17
      • 2013-07-22
      • 1970-01-01
      • 2019-03-04
      • 2013-01-22
      • 2014-08-16
      • 2012-09-23
      相关资源
      最近更新 更多