⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bytearraydatasource.java

📁 展示使用J2EE容器实现安全机制
💻 JAVA
字号:
package com.jdon.mailer.ejb;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.io.IOException;import java.io.OutputStream;import java.io.UnsupportedEncodingException;import java.util.Date;import javax.activation.DataSource;/** * Used to create a DataSource for the mail message. * @see MailHelper */class ByteArrayDataSource implements DataSource {    private byte[] data; // data for mail message    private String type; // content type/mime type   /**    * Create a DataSource from a String    * @param data is the contents of the mail message    * @param type is the mime-type such as text/html    */    ByteArrayDataSource(String data, String type) {        try {           this.data = data.getBytes("UTF-8");        } catch (UnsupportedEncodingException uex) { }        this.type = type;    }    //DataSource interface methods    public InputStream getInputStream() throws IOException {        if (data == null)            throw new IOException("no data");        return new ByteArrayInputStream(data);    }    public OutputStream getOutputStream() throws IOException {        throw new IOException("cannot do this");    }    public String getContentType() {        return type;    }    public String getName() {        return "dummy";    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -