1 54 package org.w3c.tidy; 55 56 import java.io.IOException ; 57 import java.io.OutputStream ; 58 import java.io.OutputStreamWriter ; 59 import java.io.UnsupportedEncodingException ; 60 import java.io.Writer ; 61 62 63 68 public class OutJavaImpl implements Out 69 { 70 71 74 private Writer writer; 75 76 79 private char[] newline; 80 81 88 public OutJavaImpl(Configuration configuration, String encoding, OutputStream out) 89 throws UnsupportedEncodingException 90 { 91 this.writer = new OutputStreamWriter (out, encoding); 92 this.newline = configuration.newline; 93 } 94 95 98 public void outc(int c) 99 { 100 try 101 { 102 writer.write(c); 103 } 104 catch (IOException e) 105 { 106 System.err.println("OutJavaImpl.outc: " + e.getMessage()); 108 } 109 } 110 111 114 public void outc(byte c) 115 { 116 try 117 { 118 writer.write(c); 119 } 120 catch (IOException e) 121 { 122 System.err.println("OutJavaImpl.outc: " + e.getMessage()); 124 } 125 } 126 127 130 public void newline() 131 { 132 try 133 { 134 writer.write(this.newline); 135 } 136 catch (IOException e) 137 { 138 System.err.println("OutJavaImpl.newline: " + e.getMessage()); 140 } 141 } 142 143 146 public void close() 147 { 148 try 149 { 150 writer.close(); 151 } 152 catch (IOException e) 153 { 154 System.err.println("OutJavaImpl.close: " + e.getMessage()); 155 } 156 } 157 158 } 159 | Popular Tags |