src/solaris/classes/sun/print/UnixPrintJob.java

Print this page




 975         PrintException pex;
 976 
 977         private void handleProcessFailure(final Process failedProcess,
 978                 final String[] execCmd, final int result) throws IOException {
 979             try (StringWriter sw = new StringWriter();
 980                     PrintWriter pw = new PrintWriter(sw)) {
 981                 pw.append("error=").append(Integer.toString(result));
 982                 pw.append(" running:");
 983                 for (String arg: execCmd) {
 984                     pw.append(" '").append(arg).append("'");
 985                 }
 986                 try (InputStream is = failedProcess.getErrorStream();
 987                         InputStreamReader isr = new InputStreamReader(is);
 988                         BufferedReader br = new BufferedReader(isr)) {
 989                     while (br.ready()) {
 990                         pw.println();
 991                         pw.append("\t\t").append(br.readLine());
 992                     }
 993                 } finally {
 994                     pw.flush();
 995                     throw new IOException(sw.toString());
 996                 }

 997             }
 998         }
 999 
1000         public Object run() {
1001             if (spoolFile == null || !spoolFile.exists()) {
1002                pex = new PrintException("No spool file");
1003                notifyEvent(PrintJobEvent.JOB_FAILED);
1004                return null;
1005             }
1006             try {
1007                 /**
1008                  * Spool to the printer.
1009                  */
1010                 String fileName = spoolFile.getAbsolutePath();
1011                 String execCmd[] = printExecCmd(mDestination, mOptions,
1012                                mNoJobSheet, jobName, copies, fileName);
1013 
1014                 Process process = Runtime.getRuntime().exec(execCmd);
1015                 process.waitFor();
1016                 final int result = process.exitValue();




 975         PrintException pex;
 976 
 977         private void handleProcessFailure(final Process failedProcess,
 978                 final String[] execCmd, final int result) throws IOException {
 979             try (StringWriter sw = new StringWriter();
 980                     PrintWriter pw = new PrintWriter(sw)) {
 981                 pw.append("error=").append(Integer.toString(result));
 982                 pw.append(" running:");
 983                 for (String arg: execCmd) {
 984                     pw.append(" '").append(arg).append("'");
 985                 }
 986                 try (InputStream is = failedProcess.getErrorStream();
 987                         InputStreamReader isr = new InputStreamReader(is);
 988                         BufferedReader br = new BufferedReader(isr)) {
 989                     while (br.ready()) {
 990                         pw.println();
 991                         pw.append("\t\t").append(br.readLine());
 992                     }
 993                 } finally {
 994                     pw.flush();

 995                 }
 996                 throw new IOException(sw.toString());
 997             }
 998         }
 999 
1000         public Object run() {
1001             if (spoolFile == null || !spoolFile.exists()) {
1002                pex = new PrintException("No spool file");
1003                notifyEvent(PrintJobEvent.JOB_FAILED);
1004                return null;
1005             }
1006             try {
1007                 /**
1008                  * Spool to the printer.
1009                  */
1010                 String fileName = spoolFile.getAbsolutePath();
1011                 String execCmd[] = printExecCmd(mDestination, mOptions,
1012                                mNoJobSheet, jobName, copies, fileName);
1013 
1014                 Process process = Runtime.getRuntime().exec(execCmd);
1015                 process.waitFor();
1016                 final int result = process.exitValue();