922 private File spoolFile;
923 private String mDestination, mOptions="";
924 private boolean mNoJobSheet = false;
925
926 // Inner class to run "privileged" to open the printer output stream.
927
928 private class PrinterOpener implements java.security.PrivilegedAction {
929 PrintException pex;
930 OutputStream result;
931
932 public Object run() {
933 try {
934 if (mDestType == UnixPrintJob.DESTFILE) {
935 spoolFile = new File(mDestination);
936 } else {
937 /* Write to a temporary file which will be spooled to
938 * the printer then deleted. In the case that the file
939 * is not removed for some reason, request that it is
940 * removed when the VM exits.
941 */
942 spoolFile = Files.createTempFile("javaprint", ".ps").toFile();
943 spoolFile.deleteOnExit();
944 }
945 result = new FileOutputStream(spoolFile);
946 return result;
947 } catch (IOException ex) {
948 // If there is an IOError we subvert it to a PrinterException.
949 notifyEvent(PrintJobEvent.JOB_FAILED);
950 pex = new PrintException(ex);
951 }
952 return null;
953 }
954 }
955
956 // Inner class to run "privileged" to invoke the system print command
957
958 private class PrinterSpooler implements java.security.PrivilegedAction {
959 PrintException pex;
960
961 private void handleProcessFailure(final Process failedProcess,
962 final String[] execCmd, final int result) throws IOException {
|
922 private File spoolFile;
923 private String mDestination, mOptions="";
924 private boolean mNoJobSheet = false;
925
926 // Inner class to run "privileged" to open the printer output stream.
927
928 private class PrinterOpener implements java.security.PrivilegedAction {
929 PrintException pex;
930 OutputStream result;
931
932 public Object run() {
933 try {
934 if (mDestType == UnixPrintJob.DESTFILE) {
935 spoolFile = new File(mDestination);
936 } else {
937 /* Write to a temporary file which will be spooled to
938 * the printer then deleted. In the case that the file
939 * is not removed for some reason, request that it is
940 * removed when the VM exits.
941 */
942 spoolFile = Files.createTempFile("javaprint", "").toFile();
943 spoolFile.deleteOnExit();
944 }
945 result = new FileOutputStream(spoolFile);
946 return result;
947 } catch (IOException ex) {
948 // If there is an IOError we subvert it to a PrinterException.
949 notifyEvent(PrintJobEvent.JOB_FAILED);
950 pex = new PrintException(ex);
951 }
952 return null;
953 }
954 }
955
956 // Inner class to run "privileged" to invoke the system print command
957
958 private class PrinterSpooler implements java.security.PrivilegedAction {
959 PrintException pex;
960
961 private void handleProcessFailure(final Process failedProcess,
962 final String[] execCmd, final int result) throws IOException {
|