Class PrinterUtil

Object
com.zebra.sdk.printer.PrinterUtil

public class PrinterUtil extends Object
Numerous utilities to simplify printer operations

package test.zebra.sdk.printer.examples;
 
 import java.io.IOException;
 
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.device.ZebraIllegalArgumentException;
 import com.zebra.sdk.printer.NotALinkOsPrinterException;
 import com.zebra.sdk.printer.PrinterUtil;
 import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
 
 public class PrinterUtilExample {
 
     private static final String CONNECTION_STRING = "172.30.16.135";
 
     public static void main(String[] args) throws ConnectionException, IOException, ZebraIllegalArgumentException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException {
 
         // Create a few files on the printer
         sendContentsExample();
 
         // List the files just created
         listFilesExample();
 
         // Silently delete some of the files
         deleteFilesExample();
 
         // List the remaining files
         listFilesExample();
 
         // Verbosely delete the rest of the files
         deleteFilesVerboseExample();
 
         // List the remaining files
         listFilesExample();
     }
 
     private static void sendContentsExample() throws ConnectionException, IOException {
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST1.ZPL^FO100,100^A0N,30,30^FDZSDK_Test1.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST2.ZPL^FO100,100^A0N,30,30^FDZSDK_Test2.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST3.ZPL^FO100,100^A0N,30,30^FDZSDK_Test3.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST4.ZPL^FO100,100^A0N,30,30^FDZSDK_Test4.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST11.ZPL^FO100,100^A0N,30,30^FDZSDK_Test11.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST12.ZPL^FO100,100^A0N,30,30^FDZSDK_Test12.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST22.ZPL^FO100,100^A0N,30,30^FDZSDK_Test22.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST33.ZPL^FO100,100^A0N,30,30^FDZSDK_Test33.zpl^FS^XZ");
         PrinterUtil.sendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST44.ZPL^FO100,100^A0N,30,30^FDZSDK_Test44.zpl^FS^XZ");
     }
 
     private static void listFilesExample() throws ConnectionException, ZebraIllegalArgumentException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException {
         String[] filesOnE = PrinterUtil.listFiles(CONNECTION_STRING, "R:ZSDK_TEST*.*");
         System.out.println("--- List of Files on R: ---");
         for (String thisFile : filesOnE) {
             System.out.println(" - " + thisFile);
         }
         System.out.println("--- End of List ---");
     }
 
     private static void deleteFilesExample() throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException {
         System.out.println("Deleting R:ZSDK_TEST1*.ZPL...");
         PrinterUtil.deleteFile(CONNECTION_STRING, "R:ZSDK_TEST1*.ZPL");
     }
 
     private static void deleteFilesVerboseExample() throws ConnectionException, ZebraPrinterLanguageUnknownException, ZebraIllegalArgumentException, NotALinkOsPrinterException {
         System.out.println("Verbosely Deleting R:ZSDK_TEST*.ZPL...");
         String[] filesDeleted = PrinterUtil.deleteFileReportDeleted(CONNECTION_STRING, "R:ZSDK_TEST*.ZPL");
         for (String thisDeletedFile : filesDeleted) {
             System.out.println(" - " + thisDeletedFile + " deleted");
         }
     }
 
 }
 
.