source: java/installer2/src/net/oni2/aeinstaller/backend/StringDataSource.java@ 1048

Last change on this file since 1048 was 886, checked in by alloc, 11 years ago

AEI2.16:

  • Fixes #61
  • Fixes #62
  • Adds help request dialog
File size: 880 bytes
RevLine 
[886]1package net.oni2.aeinstaller.backend;
2
3import java.io.ByteArrayInputStream;
4import java.io.IOException;
5import java.io.InputStream;
6import java.io.OutputStream;
7
8import javax.activation.DataSource;
9
10/**
11 * @author Christian Illy
12 */
13public 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.