BinaryCheckOutputStream.java
1.59 KB
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
/*
* Decompiled with CFR 0_118.
*/
package com.day.jcr.vault.util;
import java.io.IOException;
import java.io.OutputStream;
public class BinaryCheckOutputStream
extends OutputStream {
private final OutputStream out;
private boolean binary;
private static final boolean[] binaries = new boolean[256];
public BinaryCheckOutputStream(OutputStream out) {
this.out = out;
}
public boolean isBinary() {
return this.binary;
}
public void write(int b) throws IOException {
if (!this.binary) {
this.binary = binaries[b & 255];
}
this.out.write(b);
}
public void write(byte[] b) throws IOException {
for (int i = 0; i < b.length && !this.binary; ++i) {
this.binary = binaries[b[i] & 255];
}
this.out.write(b);
}
public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len && !this.binary; ++i) {
this.binary = binaries[b[i + off] & 255];
}
this.out.write(b, off, len);
}
public void flush() throws IOException {
this.out.flush();
}
public void close() throws IOException {
this.out.close();
}
static {
for (int i = 0; i < 32; ++i) {
BinaryCheckOutputStream.binaries[i] = true;
}
BinaryCheckOutputStream.binaries[13] = false;
BinaryCheckOutputStream.binaries[10] = false;
BinaryCheckOutputStream.binaries[9] = false;
BinaryCheckOutputStream.binaries[8] = false;
BinaryCheckOutputStream.binaries[12] = false;
}
}