@Override public void transmit(File file) throws PrintException { File out = new File(parent, prefix + i + suffix); try ( BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(out))) { int b; while ((b = bis.read()) != -1) { bos.write(b); } } catch (IOException e) { throw new PrintException(e); } i++; }
/** * Cancel the PrinterTask by calling the PrinterJob's cancel() method. */ public void cancel() { try { if (cancelablePrintJob != null) { cancelablePrintJob.cancel(); } } catch (PrintException ex) { logger.log(Level.FINE, "Error during printing, " + ex.getMessage()); } } }
/** * Transmit a file to the device * @param file the file to transmit * @throws FileNotFoundException * @throws PrintException */ public void transmit(File file) throws PrintException { try { transmit(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new PrintException(e); } }
/** * Transmit a file to the device * @param file the file to transmit * @throws PrintException if a print exception occurs */ @Override public void transmit(File file) throws PrintException { try { transmit(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new PrintException(e); } }
public void transmit(File file) throws PrintException { BufferedInputStream bis; BufferedOutputStream bos; File out = new File(parent, prefix + i + suffix); try { bis = new BufferedInputStream(new FileInputStream(file)); bos = new BufferedOutputStream(new FileOutputStream(out)); } catch (FileNotFoundException e) { throw new PrintException(e); } try { int b; while ((b = bis.read()) != -1) { bos.write(b); } } catch (IOException e) { throw new PrintException(e); } finally { try { bis.close(); } catch (IOException e) {} try { bos.close(); } catch (IOException e) {} } i++; }