1 17 package org.apache.servicemix.jbi.util; 18 19 import java.io.ByteArrayInputStream ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.OutputStream ; 23 import java.io.Serializable ; 24 25 import javax.activation.DataSource ; 26 27 32 public class ByteArrayDataSource implements DataSource , Serializable { 33 34 private static final long serialVersionUID = 1L; 35 36 private byte[] data; 37 private String type; 38 private String name = "unused"; 39 40 public ByteArrayDataSource(byte[] data, String type) { 41 this.data = data; 42 this.type = type; 43 } 44 45 public InputStream getInputStream() throws IOException { 46 if (data == null) throw new IOException ("no data"); 47 return new ByteArrayInputStream (data); 48 } 49 50 public OutputStream getOutputStream() throws IOException { 51 throw new IOException ("getOutputStream() not supported"); 52 } 53 54 public String getContentType() { 55 return type; 56 } 57 58 public String getName() { 59 return name; 60 } 61 62 public void setName(String name) { 63 this.name = name; 64 } 65 } | Popular Tags |