java 通过 ip地址 找到 打印机_有没有办法使用java套接字程序找到打印机状态?...

有没有办法使用

java套接字程序找到打印机状态?该程序需要确定打印机状态.如

>打印机开/关/ IDEAL.

>目前的工作.

>尝试纸张水平.

>碳粉离开.

我使用了javax.print API,这有助于我在打印机中打印文档并列出4个属性

> printer-is-accepting-jobs:接受工作

> printer-name:myPrinter

>排队作业计数:0

>支持颜色:不支持

有些人让我用snmp4j或LPR知道状态.

我用snmp写了一个应用程序.我无法成功.您可以在链接snmp application之后找到代码表.在此代码中(第38行SNMPManager客户端=新SNMPManager(“udp:127.0.0.1/161”);我们需要提供打印机的IP地址.所以我给了tcp / ip:127.0.0.1/161)我在线程“main”java.lang.IllegalArgumentException中遇到异常异常:地址类型tcp / ip unknown,我期待帮助解决这个问题.

PrintService printer = PrintServiceLookup.lookupDefaultPrintService();

AttributeSet att = printer.getAttributes();

for (Attribute a : att.toArray()) {

String attributeName;

String attributeValue;

attributeName = a.getName();

attributeValue = att.get(a.getClass()).toString();

String gh = (attributeName + " : " + attributeValue);

if (gh.equals("printer-is-accepting-jobs : not-accepting-jobs")) {

JOptionPane.showMessageDialog(rootPane, "Printer Not Available");

}

if (gh.equals("queued-job-count : 0")) {

JOptionPane.showMessageDialog(rootPane, gh);

}

System.out.println(gh);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值