java6打印机不能用_高分求解:java中调用的打印机在什么情况下不可用?
java文檔中說PrinterJob類中的getPrinterJob()方法無論返回的打印機是否可用都不會返回一個null值。我查閱過一些文獻有介紹說可以用getPrintService()方法測試返回的數值是否為null來...
java文檔中說PrinterJob類中的getPrinterJob()方法無論返回的打印機是否可用都不會返回一個null值。我查閱過一些文獻有介紹說可以用getPrintService()方法測試返回的數值是否為null來判斷打印機是否可用。
但是我不明白的是,在什么情況下打印機不可用?高分求解詳細的解答。
java文檔參考原文:
PrinterJob java.awt.print.PrinterJob.getPrinterJob()
"
Creates and returns a PrinterJob which is initially associated with the default printer. If no printers are available on the system, a PrinterJob will still be returned from this method, but getPrintService() will return null, and calling print with this PrinterJob might generate an exception. Applications that need to determine if there are suitable printers before creating a PrinterJob should ensure that the array returned from lookupPrintServices is not empty.
"
相關文檔原文參考:
"
One point you should keep in mind is that sometimes a printer may not be available on the machine on which your code is running.In this case the getPrintService() method will return null,so it's a good idea to call the method and test the reference that is returned,even if you don't want to obtain details of the printer.
"
請排除打印機損壞的情況。
展開
總結
以上是生活随笔為你收集整理的java6打印机不能用_高分求解:java中调用的打印机在什么情况下不可用?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java 逃逸分析
- 下一篇: 简述hdfs工作原理_hdfs工作机制和