File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
app/src/main/java/in/gsrathoreniks/javamail_android Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments