Retrieves a List of Printer Service Names. - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

Retrieves a List of Printer Service Names.

Demo Code


//package com.java2s;
import java.awt.print.PrinterJob;
import javax.print.PrintService;
import java.util.List;
import java.util.ArrayList;

public class Main {
    /**//from   w  w  w. ja  va  2s  .  c om
     * Retrieves a List of Printer Service Names.
     * 
     * @return List
     */
    public static List<String> getPrinterServiceNameList() {

        // get list of all print services
        PrintService[] services = PrinterJob.lookupPrintServices();
        List<String> list = new ArrayList<String>();

        for (int i = 0; i < services.length; i++) {
            list.add(services[i].getName());
        }

        return list;
    }
}

Related Tutorials