DirectIPPrintJob.java
1.95 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fd.stp.internal.print.jobs;
import com.adobe.fd.stp.api.PrinterProtocol;
import com.adobe.fd.stp.internal.exception.STPServiceException;
import com.adobe.fd.stp.internal.logging.STPServiceLogger;
import com.adobe.fd.stp.internal.print.jobs.TCPPrintJob;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class DirectIPPrintJob
extends TCPPrintJob {
private static STPServiceLogger logger = new STPServiceLogger(DirectIPPrintJob.class);
private static final int mnDefaultPortNo = 9100;
private static final String DirectIP = PrinterProtocol.DirectIP.toString();
public DirectIPPrintJob(String sPrinterUri, String sPrinterName) throws STPServiceException {
super(sPrinterUri, sPrinterName, 9100);
}
@Override
public void print(InputStream inStream) throws STPServiceException {
Socket printerSoc = null;
PrintStream printerStream = null;
String sPrinterIP = this.getServer();
try {
printerSoc = this.connect(DirectIP);
printerStream = new PrintStream(printerSoc.getOutputStream());
int bytes = 0;
byte[] chunk = new byte[8192];
while ((bytes = inStream.read(chunk)) != -1) {
printerStream.write(chunk, 0, bytes);
}
}
catch (UnknownHostException e) {
logger.error("AEM_STP_001_004", new String[]{sPrinterIP + ":" + e.getMessage()});
throw new STPServiceException("AEM_STP_001_004", new String[]{sPrinterIP}, e);
}
catch (Exception e) {
logger.error("AEM_STP_001_002", new String[]{sPrinterIP + ":" + e.getMessage()});
throw new STPServiceException("AEM_STP_001_002", new String[]{sPrinterIP}, e);
}
finally {
this.closeAll(printerSoc, null, printerStream);
}
}
}