1 37 38 package com.sun.j2ee.blueprints.opc.mailer; 39 40 41 import java.io.*; 42 import java.util.Date ; 43 import javax.activation.DataSource ; 44 45 46 50 class ByteArrayDataSource implements DataSource { 51 private byte[] data; private String type; 54 59 ByteArrayDataSource(String data, String type) { 60 try { 61 this.data = data.getBytes("UTF-8"); 62 } catch (UnsupportedEncodingException uex) { } 63 this.type = type; 64 } 65 66 68 public InputStream getInputStream() throws IOException { 69 if (data == null) 70 throw new IOException("no data"); 71 return new ByteArrayInputStream(data); 72 } 73 74 public OutputStream getOutputStream() throws IOException { 75 throw new IOException("cannot do this"); 76 } 77 78 public String getContentType() { 79 return type; 80 } 81 82 public String getName() { 83 return "dummy"; 84 } 85 } 86 87 88 | Popular Tags |