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();
}
}