Created
March 9, 2017 20:45
-
-
Save ssaurel/13b6dbfed6e8b01e152a903493218c8d to your computer and use it in GitHub Desktop.
ByteArrayDataSource for the Java Mail API on Android Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ByteArrayDataSource implements DataSource { | |
private byte[] data; | |
private String type; | |
public ByteArrayDataSource(byte[] data, String type) { | |
super(); | |
this.data = data; | |
this.type = type; | |
} | |
public ByteArrayDataSource(byte[] data) { | |
super(); | |
this.data = data; | |
} | |
public void setType(String type) { | |
this.type = type; | |
} | |
public String getContentType() { | |
if (type == null) | |
return "application/octet-stream"; | |
else | |
return type; | |
} | |
public InputStream getInputStream() throws IOException { | |
return new ByteArrayInputStream(data); | |
} | |
public String getName() { | |
return "ByteArrayDataSource"; | |
} | |
public OutputStream getOutputStream() throws IOException { | |
throw new IOException("Not Supported"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment