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

Print this page




 954                      * the printer then deleted. In the case that the file
 955                      * is not removed for some reason, request that it is
 956                      * removed when the VM exits.
 957                      */
 958                     spoolFile = Files.createTempFile("javaprint", "").toFile();
 959                     spoolFile.deleteOnExit();
 960                 }
 961                 result = new FileOutputStream(spoolFile);
 962                 return result;
 963             } catch (IOException ex) {
 964                 // If there is an IOError we subvert it to a PrinterException.
 965                 notifyEvent(PrintJobEvent.JOB_FAILED);
 966                 pex = new PrintException(ex);
 967             }
 968             return null;
 969         }
 970     }
 971 
 972     // Inner class to run "privileged" to invoke the system print command
 973 

 974     private class PrinterSpooler implements java.security.PrivilegedAction {
 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 {




 954                      * the printer then deleted. In the case that the file
 955                      * is not removed for some reason, request that it is
 956                      * removed when the VM exits.
 957                      */
 958                     spoolFile = Files.createTempFile("javaprint", "").toFile();
 959                     spoolFile.deleteOnExit();
 960                 }
 961                 result = new FileOutputStream(spoolFile);
 962                 return result;
 963             } catch (IOException ex) {
 964                 // If there is an IOError we subvert it to a PrinterException.
 965                 notifyEvent(PrintJobEvent.JOB_FAILED);
 966                 pex = new PrintException(ex);
 967             }
 968             return null;
 969         }
 970     }
 971 
 972     // Inner class to run "privileged" to invoke the system print command
 973 
 974     @SuppressWarnings("finally") // Exception always thrown in finally block
 975     private class PrinterSpooler implements java.security.PrivilegedAction {
 976         PrintException pex;
 977 
 978         private void handleProcessFailure(final Process failedProcess,
 979                 final String[] execCmd, final int result) throws IOException {
 980             try (StringWriter sw = new StringWriter();
 981                     PrintWriter pw = new PrintWriter(sw)) {
 982                 pw.append("error=").append(Integer.toString(result));
 983                 pw.append(" running:");
 984                 for (String arg: execCmd) {
 985                     pw.append(" '").append(arg).append("'");
 986                 }
 987                 try (InputStream is = failedProcess.getErrorStream();
 988                         InputStreamReader isr = new InputStreamReader(is);
 989                         BufferedReader br = new BufferedReader(isr)) {
 990                     while (br.ready()) {
 991                         pw.println();
 992                         pw.append("\t\t").append(br.readLine());
 993                     }
 994                 } finally {