691 PrinterException pex;
692
693 private void handleProcessFailure(final Process failedProcess,
694 final String[] execCmd, final int result) throws IOException {
695 try (StringWriter sw = new StringWriter();
696 PrintWriter pw = new PrintWriter(sw)) {
697 pw.append("error=").append(Integer.toString(result));
698 pw.append(" running:");
699 for (String arg: execCmd) {
700 pw.append(" '").append(arg).append("'");
701 }
702 try (InputStream is = failedProcess.getErrorStream();
703 InputStreamReader isr = new InputStreamReader(is);
704 BufferedReader br = new BufferedReader(isr)) {
705 while (br.ready()) {
706 pw.println();
707 pw.append("\t\t").append(br.readLine());
708 }
709 } finally {
710 pw.flush();
711 throw new IOException(sw.toString());
712 }
713 }
714 }
715
716 public Object run() {
717 if (spoolFile == null || !spoolFile.exists()) {
718 pex = new PrinterException("No spool file");
719 return null;
720 }
721 try {
722 /**
723 * Spool to the printer.
724 */
725 String fileName = spoolFile.getAbsolutePath();
726 String execCmd[] = printExecCmd(mDestination, mOptions,
727 mNoJobSheet, getJobNameInt(),
728 1, fileName);
729
730 Process process = Runtime.getRuntime().exec(execCmd);
731 process.waitFor();
732 final int result = process.exitValue();
|
691 PrinterException pex;
692
693 private void handleProcessFailure(final Process failedProcess,
694 final String[] execCmd, final int result) throws IOException {
695 try (StringWriter sw = new StringWriter();
696 PrintWriter pw = new PrintWriter(sw)) {
697 pw.append("error=").append(Integer.toString(result));
698 pw.append(" running:");
699 for (String arg: execCmd) {
700 pw.append(" '").append(arg).append("'");
701 }
702 try (InputStream is = failedProcess.getErrorStream();
703 InputStreamReader isr = new InputStreamReader(is);
704 BufferedReader br = new BufferedReader(isr)) {
705 while (br.ready()) {
706 pw.println();
707 pw.append("\t\t").append(br.readLine());
708 }
709 } finally {
710 pw.flush();
711 }
712 throw new IOException(sw.toString());
713 }
714 }
715
716 public Object run() {
717 if (spoolFile == null || !spoolFile.exists()) {
718 pex = new PrinterException("No spool file");
719 return null;
720 }
721 try {
722 /**
723 * Spool to the printer.
724 */
725 String fileName = spoolFile.getAbsolutePath();
726 String execCmd[] = printExecCmd(mDestination, mOptions,
727 mNoJobSheet, getJobNameInt(),
728 1, fileName);
729
730 Process process = Runtime.getRuntime().exec(execCmd);
731 process.waitFor();
732 final int result = process.exitValue();
|