Map<String, String> cdattrs = decodeRFC2231(cd); if (cdattrs != null && cdattrs.containsKey("filename")) name = cdattrs.get("filename");
MimeCompoundHeader mhdr = new MimeCompoundHeader(cd); if (mhdr.containsParameter("filename")) name = mhdr.getParameter("filename");
    public static String getFilename(MimePart mp) throws MessagingException {        String name = mp.getFileName();        // catch (legal, but uncommon) RFC 2231 encoded filenames        try {            String cd = mp.getHeader("Content-Disposition", null);            if (cd != null && cd.indexOf('*') != -1) {                // catch things like filename*=UTF-8''%E3%82%BD%E3%83%AB%E3%83%86%E3%82%A3.rtf                Map<String, String> cdattrs = decodeRFC2231(cd);                if (cdattrs != null && cdattrs.containsKey("filename"))                    name = cdattrs.get("filename");            }        } catch (MessagingException me) { }        if (name == null)            return null;        // catch (illegal, but common) RFC 2047 encoded-words        if (name.indexOf("=?") != -1 && name.indexOf("?=") != -1)            try {                return MimeUtility.decodeText(name);            } catch (UnsupportedEncodingException uee) { }        // catch (illegal, but less common) character entities        if (name.indexOf("&#") != -1 && name.indexOf(';') != -1)            return expandNumericCharacterReferences(name);        return name;    }