1 package org.simantics.document.linking.report.html;
\r
3 import java.io.BufferedInputStream;
\r
5 import java.io.FileInputStream;
\r
6 import java.io.IOException;
\r
7 import java.io.PrintStream;
\r
10 * Base class for single HTML stream.
\r
12 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
\r
16 public class HTMLStreamElement implements HTMLElement{
\r
18 protected HTMLStreamElement parent;
\r
19 protected File file;
\r
20 protected PrintStream os;
\r
22 public HTMLStreamElement(File file) throws Exception{
\r
25 os = new PrintStream(file,"UTF-8");
\r
28 public HTMLStreamElement(HTMLStreamElement parent) throws Exception{
\r
29 this.parent = parent;
\r
33 private void openStream() throws IOException {
\r
34 file = File.createTempFile("report_content", ".html");
\r
35 os = new PrintStream(file,"UTF-8");
\r
39 protected void copyData(File source, PrintStream dest)throws Exception {
\r
40 BufferedInputStream is = new BufferedInputStream(new FileInputStream(source));
\r
42 int read = is.read();
\r
50 public PrintStream getPrintStream() {
\r
55 * Closes the stream and copies the contents to the parent stream.
\r
58 public void close() throws Exception {
\r
61 if (parent != null) {
\r
62 copyData(file, parent.os);
\r
69 public String getId() {
\r