1 28 29 package com.caucho.vfs; 30 31 import java.io.IOException ; 32 import java.io.PrintWriter ; 33 import java.io.StringWriter ; 34 import java.io.Writer ; 35 import java.util.logging.Level ; 36 import java.util.logging.Logger ; 37 38 41 public class StreamPrintWriter extends PrintWriter 42 implements FlushBuffer, EnclosedWriteStream { 43 private final static Logger log 44 = Logger.getLogger(PrintWriterImpl.class.getName()); 45 46 private final static char []_nullChars = "null".toCharArray(); 47 private final static char []_newline = "\n".toCharArray(); 48 49 private final static Writer _dummyWriter = new StringWriter(); 50 51 private final WriteStream _out; 52 53 56 public StreamPrintWriter(WriteStream out) 57 { 58 super((Writer ) _dummyWriter); 59 60 _out = out; 61 } 62 63 66 final public void write(int ch) 67 { 68 try { 69 _out.print((char) ch); 70 } catch (IOException e) { 71 log.log(Level.FINE, e.toString(), e); 72 } 73 } 74 75 78 final public void write(char []buf, int offset, int length) 79 { 80 try { 81 _out.print(buf, offset, length); 82 } catch (IOException e) { 83 log.log(Level.FINE, e.toString(), e); 84 } 85 } 86 87 90 final public void write(char []buf) 91 { 92 try { 93 _out.print(buf, 0, buf.length); 94 } catch (IOException e) { 95 log.log(Level.FINE, e.toString(), e); 96 } 97 } 98 99 102 final public void write(String v) 103 { 104 try { 105 _out.print(v); 106 } catch (IOException e) { 107 log.log(Level.FINE, e.toString(), e); 108 } 109 } 110 111 114 final public void write(String v, int offset, int length) 115 { 116 try { 117 _out.print(v, offset, length); 118 } catch (IOException e) { 119 log.log(Level.FINE, e.toString(), e); 120 } 121 } 122 123 126 final public void print(char ch) 127 { 128 try { 129 _out.print(ch); 130 } catch (IOException e) { 131 log.log(Level.FINE, e.toString(), e); 132 } 133 } 134 135 138 final public void print(int v) 139 { 140 try { 141 _out.print(v); 142 } catch (IOException e) { 143 log.log(Level.FINE, e.toString(), e); 144 } 145 } 146 147 150 final public void print(long v) 151 { 152 try { 153 _out.print(v); 154 } catch (IOException e) { 155 log.log(Level.FINE, e.toString(), e); 156 } 157 } 158 159 164 final public void print(float v) 165 { 166 try { 167 _out.print(v); 168 } catch (IOException e) { 169 log.log(Level.FINE, e.toString(), e); 170 } 171 } 172 173 178 final public void print(double v) 179 { 180 try { 181 _out.print(v); 182 } catch (IOException e) { 183 log.log(Level.FINE, e.toString(), e); 184 } 185 } 186 187 190 final public void print(char []v) 191 { 192 try { 193 _out.print(v); 194 } catch (IOException e) { 195 log.log(Level.FINE, e.toString(), e); 196 } 197 } 198 199 202 final public void print(String v) 203 { 204 try { 205 _out.print(v); 206 } catch (IOException e) { 207 log.log(Level.FINE, e.toString(), e); 208 } 209 } 210 211 214 final public void print(Object v) 215 { 216 try { 217 _out.print(v); 218 } catch (IOException e) { 219 log.log(Level.FINE, e.toString(), e); 220 } 221 } 222 223 226 final public void println() 227 { 228 try { 229 _out.println(); 230 } catch (IOException e) { 231 log.log(Level.FINE, e.toString(), e); 232 } 233 } 234 235 240 final public void println(boolean v) 241 { 242 try { 243 _out.println(v); 244 } catch (IOException e) { 245 log.log(Level.FINE, e.toString(), e); 246 } 247 } 248 249 254 final public void println(char v) 255 { 256 try { 257 _out.println(v); 258 } catch (IOException e) { 259 log.log(Level.FINE, e.toString(), e); 260 } 261 } 262 263 268 final public void println(int v) 269 { 270 try { 271 _out.println(v); 272 } catch (IOException e) { 273 log.log(Level.FINE, e.toString(), e); 274 } 275 } 276 277 282 final public void println(long v) 283 { 284 try { 285 _out.println(v); 286 } catch (IOException e) { 287 log.log(Level.FINE, e.toString(), e); 288 } 289 } 290 291 296 final public void println(float v) 297 { 298 try { 299 _out.println(v); 300 } catch (IOException e) { 301 log.log(Level.FINE, e.toString(), e); 302 } 303 } 304 305 310 final public void println(double v) 311 { 312 try { 313 _out.println(v); 314 } catch (IOException e) { 315 log.log(Level.FINE, e.toString(), e); 316 } 317 } 318 319 322 final public void println(char []v) 323 { 324 try { 325 _out.println(v); 326 } catch (IOException e) { 327 log.log(Level.FINE, e.toString(), e); 328 } 329 } 330 331 334 final public void println(String v) 335 { 336 try { 337 _out.println(v); 338 } catch (IOException e) { 339 log.log(Level.FINE, e.toString(), e); 340 } 341 } 342 343 346 final public void println(Object v) 347 { 348 try { 349 _out.println(v); 350 } catch (IOException e) { 351 log.log(Level.FINE, e.toString(), e); 352 } 353 } 354 355 358 public void flush() 359 { 360 try { 361 _out.flush(); 362 } catch (IOException e) { 363 log.log(Level.FINE, e.toString(), e); 364 } 365 } 366 367 370 public void flushBuffer() 371 { 372 try { 373 _out.flushBuffer(); 374 } catch (IOException e) { 375 log.log(Level.FINE, e.toString(), e); 376 } 377 } 378 379 public WriteStream getWriteStream() 380 { 381 return _out; 382 } 383 384 public void close() 385 { 386 } 387 } 388 | Popular Tags |