Rev | Line | |
---|
[886] | 1 | package net.oni2.aeinstaller.backend;
|
---|
| 2 |
|
---|
| 3 | import java.io.ByteArrayInputStream;
|
---|
| 4 | import java.io.IOException;
|
---|
| 5 | import java.io.InputStream;
|
---|
| 6 | import java.io.OutputStream;
|
---|
| 7 |
|
---|
| 8 | import javax.activation.DataSource;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * @author Christian Illy
|
---|
| 12 | */
|
---|
| 13 | public class StringDataSource implements DataSource {
|
---|
| 14 |
|
---|
| 15 | private String str;
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * Create a SDS from the given string
|
---|
| 19 | *
|
---|
| 20 | * @param str
|
---|
| 21 | * String to represent
|
---|
| 22 | */
|
---|
| 23 | public StringDataSource(String str) {
|
---|
| 24 | this.str = str;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | @Override
|
---|
| 28 | public String getContentType() {
|
---|
| 29 | return "text/plain";
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
| 33 | public InputStream getInputStream() throws IOException {
|
---|
| 34 | return new ByteArrayInputStream(str.getBytes());
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | @Override
|
---|
| 38 | public String getName() {
|
---|
| 39 | return "<unknown>";
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | @Override
|
---|
| 43 | public OutputStream getOutputStream() throws IOException {
|
---|
| 44 | throw new IOException("Can not write to the string data source");
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.