简体   繁体   English

如何使用Java知道网络打印机的状态?

[英]How to know the Network printer status using java?

To check the current status of the default printer we can using a Java API. 要检查默认打印机的当前状态,我们可以使用Java API。 we need to over right attributeUpdate method. 我们需要正确的attributeUpdate方法。

@Override
    public void attributeUpdate(PrintServiceAttributeEvent psae)
    {

        Attribute[] att;
        att = psae.getAttributes().toArray();
        for (Attribute attribute : att)
            {
                System.out.println(attribute.toString());
            }
    } 

But My Question here is will it send the request to physical printer and give us response or just check the driver installation form our local machine and give us the status? 但是我的问题是,它将请求发送到物理打印机并给我们答复,还是只是检查本地计算机上的驱动程序安装并给我们状态? If its from local machine, how can i send the request to physical printer and get the response? 如果来自本地计算机,如何将请求发送到物理打印机并获得响应?

It will just query the local machine to determine attributes. 它将仅查询本地计算机以确定属性。 If you want to actually send a packet, then you should use snmp4j or LPR 如果要实际发送数据包,则应使用snmp4jLPR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM