Here you can find the source of getPrintService(String printername)
public static PrintService getPrintService(String printername)
//package com.java2s; // it under the terms of the GNU General Public License as published by import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; public class Main { public static PrintService getPrintService(String printername) { // Initalize print service if (printername == null) { return PrintServiceLookup.lookupDefaultPrintService(); } else {/*from ww w.ja va 2s. com*/ if ("(Show dialog)".equals(printername)) { return null; // null means "you have to show the print dialog" } else if ("(Default)".equals(printername)) { return PrintServiceLookup.lookupDefaultPrintService(); } else { PrintService[] pservices = PrintServiceLookup .lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null); for (PrintService s : pservices) { if (printername.equals(s.getName())) { return s; } } return PrintServiceLookup.lookupDefaultPrintService(); } } } }