title: Java: How to check if printer status
body: <p>I'm looking for a method to check some Status from my Printer.
  I'd like to know These Status:</p>
  
  <ul>
  <li>If Printer is on / off</li>
  <li>If paper is out</li>
  <li>Maybe a way to get Default paper size?</li>
  </ul>
  
  <p>I've found this code part:</p>
  
  <pre><code>Attribute[] attrs = service.getAttributes().toArray();
  
  for (Attribute attr : attrs) {
      String attrName = attr.getName();
      String attrValue = attr.toString();
  
      System.out.println("Found attribute: " + attrName + " with value: " + attrValue);
  }
  </code></pre>
  
  <p>This part works fine and gives me this Output:
  <a href="https://i.stack.imgur.com/LlbBL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LlbBL.jpg" alt="enter image description here"></a></p>
  
  <p>But I didn't found a way to get the Information I want.</p>
  
  <p>I've also tried this.</p>
  
  <pre><code>AttributeSet attributes = service.getAttributes();
  String printerState = attributes.get(PrinterState.class).toString();
  
  System.out.println("printerState = " + printerState); 
  </code></pre>
  
  <p>But printerState is always <code>null</code>.</p>