Using the Guardian printer

NonStop Java API accepts the Guardian printer filenames.

The following code fragment shows how to set the Guardian printer filename and print the print.txt file:

..
String printer = "$s.#p255";
FileInputStream stream = new FileInputStream("print.txt"); // file to print
..
PrintServiceAttributeSet prAttr = new HashPrintServiceAttributeSet();
prAttr.add(new PrinterName(printer, null));
PrintServiceLookup lookup = new UnixPrintServiceLookup();
PrintService[] services = null;
..
services = lookup.getPrintServices(null, prAttr);
..
DocPrintJob job = services[0].createPrintJob();
SimpleDoc doc = new SimpleDoc(stream, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
..
job.print(doc, null);
..
..

In the code fragment, $s.#p255 is the name of the configured printer. If there is no printer configured with this name, then print output is routed to Spooler with location #p255. To print the document, you need to explicitly reroute the document to the configured printer location. For more information, see Spooler Utilities Reference Manual.