Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/11/2016, 11:40
udok
 
Fecha de Ingreso: diciembre-2013
Mensajes: 16
Antigüedad: 10 años, 4 meses
Puntos: 1
Respuesta: ¿Cómo abrir cajón portamonedas en Java?

La impresora esta predeterminada, esto es el método que tengo y no funciona:
Código:
public void cashdrawerOpen() {

		String code1 = "27 112 0 150 250";
		String code = "ESCp0û.";
		 FileInputStream inputStream = null;
	        try {
	            inputStream = new FileInputStream(code1);
	              
	        } catch (FileNotFoundException e) {
	            e.printStackTrace();
	        }
	        if (inputStream == null) {
	            return;
	        }
	 
	        DocFlavor docFormat = DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII;
	        Doc document = new SimpleDoc(inputStream, docFormat, null);
	 
	        PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
	 
	        PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
	 
	 
	        if (defaultPrintService != null) {
	            DocPrintJob printJob = defaultPrintService.createPrintJob();
	            try {
	                printJob.print(document, attributeSet);
	 
	            } catch (Exception e) {
	                e.printStackTrace();
	            }
	        } else {
	            System.err.println("No existen impresoras instaladas");
	        }
	 
	        try {
				inputStream.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }