Example usage for javax.print.attribute PrintServiceAttributeSet toArray

List of usage examples for javax.print.attribute PrintServiceAttributeSet toArray

Introduction

In this page you can find the example usage for javax.print.attribute PrintServiceAttributeSet toArray.

Prototype

public Attribute[] toArray();

Source Link

Document

Returns an array of the attributes contained in this set.

Usage

From source file:Main.java

static public void main(String args[]) throws Exception {
    PrintService pss[] = PrintServiceLookup.lookupPrintServices(null, null);
    for (int i = 0; i < pss.length; ++i) {
        System.out.println(pss[i]);
        PrintService ps = pss[i];

        PrintServiceAttributeSet psas = ps.getAttributes();
        Attribute attributes[] = psas.toArray();
        for (int j = 0; j < attributes.length; ++j) {
            Attribute attribute = attributes[j];
            System.out.println("  attribute: " + attribute.getName());
            if (attribute instanceof PrinterName) {
                System.out.println("    printer name: " + ((PrinterName) attribute).getValue());
            }/*w ww  .  ja v  a2 s.c o m*/
        }
        DocFlavor supportedFlavors[] = ps.getSupportedDocFlavors();
        for (int j = 0; j < supportedFlavors.length; ++j) {
            System.out.println("  flavor: " + supportedFlavors[j]);
        }
    }
}