1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
// java.io.PrintStream
// An implementation of the Java Language Specification section 22.22
// Written by Charles Briscoe-Smith; refer to the file LEGAL for details.
package java.io;
public class PrintStream extends FilterOutputStream {
private boolean autoflush;
private boolean error=false;
public PrintStream(OutputStream out) {
this(out, false);
}
public PrintStream(OutputStream out, boolean autoflush) {
super(out);
this.autoflush=autoflush;
}
public void write(int b) {
try {
out.write(b);
if (b=='\n' && autoflush) flush();
// } catch (InterruptedIOException e) {
// Thread.currentThread().interrupt();
} catch (IOException e) {
error=true;
}
}
public void write(byte[] b, int off, int len)
throws NullPointerException, IndexOutOfBoundsException
{
try {
out.write(b, off, len);
if (autoflush) flush();
// } catch (InterruptedIOException e) {
// Thread.currentThread().interrupt();
} catch (IOException e) {
error=true;
}
}
public void flush()
{
try {
out.flush();
// } catch (InterruptedIOException e) {
// Thread.currentThread().interrupt();
} catch (IOException e) {
error=true;
}
}
public void close()
{
try {
out.flush();
out.close();
// } catch (InterruptedIOException e) {
// Thread.currentThread().interrupt();
} catch (IOException e) {
error=true;
}
}
public boolean checkError()
{
return error;
}
public void print(Object o) {
print(String.valueOf(o));
}
public void print(String s) {
if (s==null) {
s="null";
}
int i=0;
while (i<s.length()) {
write((int) s.charAt(i));
i++;
}
}
public void print(char[] s) {
for (int i=0; i<s.length; i++) {
write((int) s[i]);
}
}
public void print(boolean b) {
if (b)
print("true");
else
print("false");
}
public void print(char c) {
write((int) c);
}
public void print(int i) {
print (Integer.toString(i));
}
public void print(long l) {
print (Long.toString(l));
}
// public void print(float f) {
// print (Float.toString(f));
// }
// public void print(double d) {
// print (Double.toString(d));
// }
public void println() {
print("\n");
}
public void println(Object o) {
print(o);
println();
}
public void println(String s) {
print(s);
println();
}
public void println(char[] s) throws NullPointerException {
print(s);
println();
}
public void println(boolean b) {
print(b);
println();
}
public void println(char c) {
print(c);
println();
}
public void println(int i) {
print(i);
println();
}
public void println(long l) {
print(l);
println();
}
// public void println(float f) {
// print(f);
// println();
// }
// public void println(double d) {
// print(d);
// println();
// }
}
|