Here you can find the source of findPrintService(String printerName)
public static PrintService findPrintService(String printerName)
//package com.java2s; //License from project: Open Source License import javax.print.PrintService; import javax.print.PrintServiceLookup; public class Main { public static PrintService findPrintService(String printerName) { PrintService printService = null; if (printerName == null || printerName.isEmpty()) { printService = PrintServiceLookup.lookupDefaultPrintService(); } else {//from w w w .ja v a2s . c o m PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); for (PrintService service : services) { String prtName = service.getName(); if (prtName.contains(printerName)) { printService = service; break; } } } return printService; } }