开发者

Is PrinterUri attribute ignored by Java PrintService?

I'm using the following code in order to send a print job to a specific printer:

PrintServiceAttributeSet aset = new HashPrintServiceAttributeSet();
     try {
            aset.add(new PrinterURI(new URI("ipp://hostName/printerName")));
        } catch (URISyntaxException e) {
            System.out.println("URI exception caught: "+e);
        }
        PrintService[] services =
            PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT,aset);  

Strangley, I get 9 lookup results (=all available printers on that specific host) - while only the first result is the one I'm seeking. I searched 开发者_开发百科in the PrintService JavaDocs, and on the web - but found nothing on the matter.

Isn't PrintServiceLookup expected to return only the printers which match my request? (in this case - one printer)

Thanks in advance!


It turns out that the URI I was using was wrong (yet with a valid syntax, so no exception was thrown).
So answering my initial question - Java PrintService ignores an attribute which is wrong (as opposed to my expectation, that PrintService would return no result in case of a wrong attribute).

Thanks anyway

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜