ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/installer2/src/net/oni2/aeinstaller/backend/StringDataSource.java
Revision: 886
Committed: Mon Jun 24 18:06:11 2013 UTC (12 years, 3 months ago) by alloc
Content type: text/x-java
File size: 880 byte(s)
Log Message:
AEI2.16:
- Fixes #61
- Fixes #62
- Adds help request dialog

File Contents

# Content
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 }