1 23 24 package org.infoglue.cms.util.mail; 25 26 import java.io.ByteArrayInputStream ; 27 import java.io.IOException ; 28 import java.io.InputStream ; 29 import java.io.OutputStream ; 30 31 import javax.activation.DataSource ; 32 33 36 public class ByteDataSource implements DataSource 37 { 38 41 private byte[] data; 42 43 46 private String type; 47 48 51 public ByteDataSource(final byte[] data, final String type) 52 { 53 this.data = data; 54 this.type = type; 55 } 56 57 60 public InputStream getInputStream() throws IOException 61 { 62 if (data == null) 63 { 64 throw new IOException ("no data"); 65 } 66 67 return new ByteArrayInputStream (data); 68 } 69 70 public OutputStream getOutputStream() throws IOException 71 { 72 throw new IOException ("cannot do this"); 73 } 74 75 public String getContentType() 76 { 77 return type; 78 } 79 80 public String getName() 81 { 82 return "dummy"; 83 } 84 } | Popular Tags |