Я не могу получить PrinterState моих принтеров. Я тестировал следующий код в Linux и Windows (7) с разными принтерами (Samsung, Brother (только в Linux), Zebra, ...). Но в каждом случае объекты PrinterState и PrinterStateReasons имеют значение NULL.Почему PrinterState всегда возвращает null?
private void dumpPrinterState() {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); //get printers
for (PrintService printService : printServices) {
log.info("---- printer: " + printService);
log.info("---- state: " + printService.getAttribute(PrinterState.class));
log.info("---- reason: " + printService.getAttribute(PrinterStateReasons.class));
}
}
Вот результат моей попытки на Windows:
---- printer: Win32 Printer : ZDesigner KR403
---- state: null
---- reason: null
---- printer: Win32 Printer : Samsung CLP-300 Series
---- state: null
---- reason: null
---- printer: Win32 Printer : Microsoft XPS Document Writer
---- state: null
---- reason: null
---- printer: Win32 Printer : Fax
---- state: null
---- reason: null
Кто-нибудь знает, что случилось?
По какой-то причине PrinterState & PrinterStateReasons не поддерживает, printService.getSupportedAttributeCategories() не вернул их – whizzzkey