public void cashdrawerOpen() {
byte[] open = {27, 112, 48, 55, 121};
String printer = PrinterName;
PrintServiceAttributeSet printserviceattributeset = new HashPrintServiceAttributeSet();
printserviceattributeset.add(new PrinterName(printer,null));
PrintService[] printservice = PrintServiceLookup.lookupPrintServices(null, printserviceattributeset);
if(printservice.length!=1){
System.out.println("Printer not found");
}
PrintService pservice = printservice[0];
DocPrintJob job = pservice.createPrintJob();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(open,flavor,null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
try {
job.print(doc, aset);
} catch (PrintException ex) {
System.out.println(ex.getMessage());
}
}