本文整理了Java中javax.mail.internet.MimeBodyPart.getFileName()
方法的一些代码示例,展示了MimeBodyPart.getFileName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeBodyPart.getFileName()
方法的具体详情如下:
包路径:javax.mail.internet.MimeBodyPart
类名称:MimeBodyPart
方法名:getFileName
[英]Get the filename associated with this body part.
Returns the value of the "filename" parameter from the "Content-Disposition" header field of this body part. If its not available, returns the value of the "name" parameter from the "Content-Type" header field of this body part. Returns null
if both are absent.
If the mail.mime.decodefilename
System property is set to true, the MimeUtility#decodeText method will be used to decode the filename. While such encoding is not supported by the MIME spec, many mailers use this technique to support non-ASCII characters in filenames. The default value of this property is false.
[中]获取与此身体部位关联的文件名。
从该正文部分的“内容处置”标题字段返回“filename”参数的值。如果不可用,则从该正文部分的“内容类型”标题字段返回“名称”参数的值。如果两者都不存在,则返回null
。
如果mail.mime.decodefilename
系统属性设置为true,则将使用MimeUtility#decodeText方法对文件名进行解码。虽然MIME规范不支持这种编码,但许多邮件程序使用这种技术来支持文件名中的非ASCII字符。此属性的默认值为false。
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Get the filename associated with this body part. <p>
*
* Returns the value of the "filename" parameter from the
* "Content-Disposition" header field of this body part. If its
* not available, returns the value of the "name" parameter from
* the "Content-Type" header field of this body part.
* Returns <code>null</code> if both are absent. <p>
*
* If the <code>mail.mime.decodefilename</code> System property
* is set to true, the {@link MimeUtility#decodeText
* MimeUtility.decodeText} method will be used to decode the
* filename. While such encoding is not supported by the MIME
* spec, many mailers use this technique to support non-ASCII
* characters in filenames. The default value of this property
* is false.
*
* @return filename
*/
public String getFileName() throws MessagingException {
return getFileName(this);
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Get the filename associated with this Message. <p>
*
* Returns the value of the "filename" parameter from the
* "Content-Disposition" header field of this message. If it's
* not available, returns the value of the "name" parameter from
* the "Content-Type" header field of this BodyPart.
* Returns <code>null</code> if both are absent. <p>
*
* If the <code>mail.mime.encodefilename</code> System property
* is set to true, the {@link MimeUtility#decodeText
* MimeUtility.decodeText} method will be used to decode the
* filename. While such encoding is not supported by the MIME
* spec, many mailers use this technique to support non-ASCII
* characters in filenames. The default value of this property
* is false.
*
* @return filename
* @exception MessagingException for failures
*/
public String getFileName() throws MessagingException {
return MimeBodyPart.getFileName(this);
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Get the filename associated with this body part. <p>
*
* Returns the value of the "filename" parameter from the
* "Content-Disposition" header field of this body part. If its
* not available, returns the value of the "name" parameter from
* the "Content-Type" header field of this body part.
* Returns <code>null</code> if both are absent. <p>
*
* If the <code>mail.mime.decodefilename</code> System property
* is set to true, the {@link MimeUtility#decodeText
* MimeUtility.decodeText} method will be used to decode the
* filename. While such encoding is not supported by the MIME
* spec, many mailers use this technique to support non-ASCII
* characters in filenames. The default value of this property
* is false.
*
* @return filename
*/
@Override
public String getFileName() throws MessagingException {
return getFileName(this);
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Get the filename associated with this Message. <p>
*
* Returns the value of the "filename" parameter from the
* "Content-Disposition" header field of this message. If it's
* not available, returns the value of the "name" parameter from
* the "Content-Type" header field of this BodyPart.
* Returns <code>null</code> if both are absent. <p>
*
* If the <code>mail.mime.encodefilename</code> System property
* is set to true, the {@link MimeUtility#decodeText
* MimeUtility.decodeText} method will be used to decode the
* filename. While such encoding is not supported by the MIME
* spec, many mailers use this technique to support non-ASCII
* characters in filenames. The default value of this property
* is false.
*
* @return filename
* @exception MessagingException for failures
*/
@Override
public String getFileName() throws MessagingException {
return MimeBodyPart.getFileName(this);
}
代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec
public String getName() {
try {
if (part instanceof MimeBodyPart) {
return ((MimeBodyPart) part).getFileName();
}
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: javax.mail/com.springsource.javax.mail
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: javax.mail/javax.mail-api
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: com.sun.mail/android-mail
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: jboss/jboss-javaee-specs
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: com.sun.mail/mailapi
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: com.sun.mail/jakarta.mail
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: org.glassfish.metro/webservices-extra
/**
* DataSource method to return a name. <p>
*
* This implementation just returns an empty string.
*/
@Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
return ((MimeBodyPart)part).getFileName();
} catch (MessagingException mex) {
// ignore it
}
return "";
}
代码示例来源:origin: camunda/camunda-bpm-platform
String name = parts[i].getFileName();
if (isEmpty(name)) { //Exceptional case.
name = toString(attachmentFormatters[i]);
代码示例来源:origin: com.sun.mail/javax.mail
String name = parts[i].getFileName();
if (isEmpty(name)) { //Exceptional case.
name = toString(attachmentFormatters[i]);
代码示例来源:origin: org.apache.james/apache-mailet-icalendar
private void setFileNameIfNeeded(MimeBodyPart mimeBodyPart) throws MessagingException {
if (mimeBodyPart.getFileName() == null) {
mimeBodyPart.setFileName(DEFAULT_FILENAME);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail
/**
* Get the filename associated with this BodyPart. <p>
*
* Returns the value of the "filename" parameter from the
* "Content-Disposition" header field of this BodyPart. If its
* not available, returns the value of the "name" parameter from
* the "Content-Type" header field of this BodyPart.
* Returns <code>null</code> if both are absent.
*
* @return filename
*/
public String getFileName() throws MessagingException {
String name = super.getFileName();
if (name == null)
name = getHeader("X-Sun-Data-Name", null);
return name;
}
代码示例来源:origin: stackoverflow.com
MimeMultipart multipart = (MimeMultipart) message.getContent();
System.out.println("This message consists of " + multipart.getCount() + " parts");
for (int i = 0; i < multipart.getCount(); i++) {
// Note we're downcasting here, MimeBodyPart is the only subclass
// of BodyPart available in the Java EE spec.
MimeBodyPart bodyPart = (MimeBodyPart) multipart.getBodyPart(i);
System.out.println("Part " + i + " has type " + bodyPart.getContentType());
System.out.println("Part " + i " + has filename " + bodyPart.getFileName()); // if it was an attachment
// So on, so forth.
}
内容来源于网络,如有侵权,请联系作者删除!