Class ByteArrayAttachment
java.lang.Object
cloud.opencode.base.email.attachment.ByteArrayAttachment
- All Implemented Interfaces:
Attachment
Byte Array Email Attachment
字节数组邮件附件
Attachment implementation for in-memory byte data.
内存字节数据的附件实现。
Features | 主要功能:
- In-memory data - 内存数据
- No file system dependency - 无文件系统依赖
- Defensive copy for security - 防御性拷贝确保安全
Usage Examples | 使用示例:
byte[] data = generatePdfReport();
Attachment attachment = new ByteArrayAttachment("report.pdf", data, "application/pdf");
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Immutable: Yes (defensive copy) - 不可变: 是(防御性拷贝)
- Since:
- JDK 25, opencode-base-email V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionByteArrayAttachment(String fileName, byte[] data) Create byte array attachment 创建字节数组附件ByteArrayAttachment(String fileName, byte[] data, String contentType) Create byte array attachment with content type 创建带内容类型的字节数组附件 -
Method Summary
Modifier and TypeMethodDescriptionGet attachment MIME type 获取附件MIME类型byte[]getData()Get a copy of the byte data 获取字节数据的拷贝Get attachment file name 获取附件文件名Get attachment data as input stream 获取附件数据输入流longgetSize()Get attachment size in bytes 获取附件大小(字节)static ByteArrayAttachmentCreate byte array attachment 创建字节数组附件static ByteArrayAttachmentCreate byte array attachment 创建字节数组附件toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Attachment
getContentId, isInline
-
Constructor Details
-
ByteArrayAttachment
Create byte array attachment 创建字节数组附件- Parameters:
fileName- the file name | 文件名data- the byte data | 字节数据
-
ByteArrayAttachment
-
-
Method Details
-
of
Create byte array attachment 创建字节数组附件- Parameters:
fileName- the file name | 文件名data- the byte data | 字节数据contentType- the MIME type | MIME类型- Returns:
- the byte array attachment | 字节数组附件
-
of
Create byte array attachment 创建字节数组附件- Parameters:
fileName- the file name | 文件名data- the byte data | 字节数据- Returns:
- the byte array attachment | 字节数组附件
-
getFileName
Description copied from interface:AttachmentGet attachment file name 获取附件文件名- Specified by:
getFileNamein interfaceAttachment- Returns:
- the file name | 文件名
-
getContentType
Description copied from interface:AttachmentGet attachment MIME type 获取附件MIME类型- Specified by:
getContentTypein interfaceAttachment- Returns:
- the MIME type | MIME类型
-
getInputStream
Description copied from interface:AttachmentGet attachment data as input stream 获取附件数据输入流- Specified by:
getInputStreamin interfaceAttachment- Returns:
- the input stream | 输入流
-
getSize
public long getSize()Description copied from interface:AttachmentGet attachment size in bytes 获取附件大小(字节)- Specified by:
getSizein interfaceAttachment- Returns:
- the size in bytes | 字节大小
-
getData
public byte[] getData()Get a copy of the byte data 获取字节数据的拷贝- Returns:
- copy of the data | 数据拷贝
-
toString
-