Skip to content

Commit 66b90dd

Browse files
committed
Model class added for data
1 parent 98d912d commit 66b90dd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package in.gsrathoreniks.javamail_android;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.io.OutputStream;
7+
import javax.activation.DataSource;
8+
9+
public class ByteArrayDataSource implements DataSource {
10+
private byte[] data;
11+
private String type;
12+
13+
public ByteArrayDataSource(byte[] data, String type) {
14+
super();
15+
this.data = data;
16+
this.type = type;
17+
}
18+
19+
public ByteArrayDataSource(byte[] data) {
20+
super();
21+
this.data = data;
22+
}
23+
24+
public void setType(String type) {
25+
this.type = type;
26+
}
27+
28+
public String getContentType() {
29+
if (type == null)
30+
return "application/octet-stream";
31+
else
32+
return type;
33+
}
34+
35+
public InputStream getInputStream() throws IOException {
36+
return new ByteArrayInputStream(data);
37+
}
38+
39+
public String getName() {
40+
return "ByteArrayDataSource";
41+
}
42+
43+
public OutputStream getOutputStream() throws IOException {
44+
throw new IOException("Not Supported");
45+
}
46+
}

0 commit comments

Comments
 (0)