1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.t7mp.util;
17
18 import java.io.IOException;
19 import java.io.OutputStream;
20 import java.io.PrintStream;
21
22
23
24
25
26
27 public final class CatalinaOutPrintStream extends PrintStream {
28
29 private final PrintStream originalSystemErr;
30 private final boolean suspendConsoleOutput;
31
32 public CatalinaOutPrintStream(PrintStream originalSystemErr, OutputStream outputStream, boolean suspendConsoleOutput)
33 throws IOException {
34 super(outputStream, true);
35 this.originalSystemErr = originalSystemErr;
36 this.suspendConsoleOutput = suspendConsoleOutput;
37 }
38
39 public PrintStream getOriginalSystemErr() {
40 return this.originalSystemErr;
41 }
42
43 @Override
44 public boolean checkError() {
45 return originalSystemErr.checkError() || super.checkError();
46 }
47
48 @Override
49 public void write(int x) {
50 if (!suspendConsoleOutput) {
51 originalSystemErr.write(x);
52 }
53 super.write(x);
54 }
55
56 @Override
57 public void write(byte[] x, int o, int l) {
58 if (!suspendConsoleOutput) {
59 originalSystemErr.write(x, o, l);
60 }
61 super.write(x, o, l);
62 }
63
64 @Override
65 public void close() {
66 super.close();
67 }
68
69 @Override
70 public void flush() {
71 originalSystemErr.flush();
72 super.flush();
73 }
74
75 }