java - java中如何获取打印机列表?

标签 java printers

如何显示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]);

但我希望在控制台中显示所有打印机。我怎样才能实现这个目标?

最佳答案

尝试

PrintServiceLookup.lookupPrintServices(null, null);

这将返回 PrintService[],其中包含系统可用的所有打印机。

关于java - java中如何获取打印机列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15274328/

相关文章:

java - 对于这种情况有什么正确的注释。 JPA。 hibernate

java - 如何在 JPA 中实现复杂的多对多关系?

linux - 在 Linux 上安装 npm 模块(打印机)时出错

printing - 使用 maskdict 在 postscript 中进行图像屏蔽

java - Java PrintService 是否忽略 PrinterUri 属性?

android - 如何下载和构建 libijs 源?

java - 在 JPanel 中插入按钮

java - 改变 HashBiMap 中的值是否安全?

java - 使用光栅 PTR 打印机在 Java 中打印文件

JavaFX - StackPane 组件跳转