package at.gv.egiz.pdfas.web.io; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; import at.gv.egiz.pdfas.api.io.DataSource; /** * * @author exthex * */ public class TextDataSource implements DataSource { private String text; public TextDataSource(String text) { this.text = text; } public InputStream createInputStream() { try { return new ByteArrayInputStream(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } public int getLength() { return 0; } public byte[] getAsByteArray() { try{ return text.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } public String getMimeType() { return "text/plain"; } public String getCharacterEncoding() { return "UTF-8"; } }