StreamGobbler.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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.pdfg.logging.PDFGLogger
*/
package com.adobe.pdfg.common;
import com.adobe.pdfg.logging.PDFGLogger;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class StreamGobbler
extends Thread {
private final int BUFLEN = 512;
private byte[] buffer = new byte[512];
private PDFGLogger pdfgLogger = PDFGLogger.getPDFGLogger(StreamGobbler.class);
final InputStream is;
final OutputStream copyTo;
public StreamGobbler(String name, InputStream is, OutputStream copyTo) {
super(name);
this.setDaemon(true);
this.is = is;
this.copyTo = copyTo;
}
public void run() {
try {
int bytesRead;
while (!StreamGobbler.interrupted() && (bytesRead = this.is.read(this.buffer)) != -1) {
if (this.copyTo == null) continue;
this.copyTo.write(this.buffer, 0, bytesRead);
}
}
catch (IOException e) {
this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
}
try {
this.is.close();
}
catch (IOException e) {
this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
}
}
public void collectThread() {
this.interrupt();
try {
this.join(1000);
}
catch (InterruptedException e) {
this.pdfgLogger.trace(e.getMessage(), null, (Throwable)e);
}
if (this.isAlive()) {
this.interrupt();
}
}
}