2013-03-07 108 views
1

如何顯示設備上安裝的所有打印機Java如何獲取java中的打印機列表?

到目前爲止找到我的打印機使用:

PrintUtility.findPrintService(printer); //Selects any printer with the name provided 
    PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, null); 
    //System.out.println("Printers avialiable are " + services); 
    System.out.println("Printer Selected " + services[Printerinx]); 

不過,我想在控制檯中顯示,所有打印機。我怎樣才能做到這一點?

+1

假設lookupPrintServices返回所有打印機,顯示數組用戶Arrays.toString(services) – orangegoat 2013-03-07 14:57:08

回答

2

嘗試

PrintServiceLookup.lookupPrintServices(null, null); 

這將返回的PrintService [],瀰漫着系統中所有可用的打印機。