1 51 package org.apache.fop.render.txt; 52 53 import java.io.*; 54 55 public class TXTStream { 56 OutputStream out = null; 57 boolean doOutput = true; 58 private String encoding; 59 60 public TXTStream(OutputStream os) { 61 out = os; 62 } 63 64 public void add(String str) { 65 if (!doOutput) 66 return; 67 68 try { 69 byte buff[] = str.getBytes(encoding); 70 out.write(buff); 71 } catch (IOException e) { 72 throw new RuntimeException (e.toString()); 73 } 74 } 75 76 public void setDoOutput(boolean doout) { 77 doOutput = doout; 78 } 79 80 public void setEncoding(String encoding) { 81 if (encoding != null) 82 this.encoding = encoding; 83 else 84 this.encoding = "UTF-8"; 85 } 86 } 87 | Popular Tags |