This example program presents a list of spooled files on the server. All spooled files, or only spooled files for a specific user, can be displayed.
//////////////////////////////////////////////////////////////////////////////////
//
// VPrinterOutput example. This program presents a list of spooled
// files on the server. All spooled files, or spooled files for
// a specific user can be displayed.
//
// Command syntax:
// VPrinterOutputExample system <user>
//
// (User is optional, if not specified all spooled files on the system
// will be displayed. Caution - listing all spooled files on the system
// and take a long time)
//
//////////////////////////////////////////////////////////////////////////////////
import com.ibm.as400.access.*;
import com.ibm.as400.vaccess.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class VPrinterOutputExample
{
public static void main (String[] args)
{
// If a system was not specified, display help text and exit.
if (args.length == 0)
{
System.out.println("Usage: VPrinterOutputExample system <user>");
return;
}
try
{
// Create an AS400 object. The system name was passed
// as the first command line argument.
AS400 system = new AS400 (args[0]);
system.connectService(AS400.PRINT);
// Create the VPrinterOutput object.
VPrinterOutput printerOutput = new VPrinterOutput(system);
// If a user was specified as a command line parameter, tell
// the printerObject to get spooled files only for that user.
if (args.length > 1)
printerOutput.setUserFilter(args[1]);
// Create a frame to hold our window.
JFrame f = new JFrame ("VPrinterOutput Example");
// Create an error dialog adapter. This will display
// any errors to the user.
ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f);
// Create an details pane to present the list of spooled files.
// Use load to load the information from the system.
AS400DetailsPane detailsPane = new AS400DetailsPane (printerOutput);
detailsPane.addErrorListener (errorHandler);
detailsPane.load ();
// When the frame closes, exit.
f.addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent event)
{
System.exit (0);
}
});
// Layout the frame with the details pane.
f.getContentPane ().setLayout (new BorderLayout ());
f.getContentPane ().add ("Center", detailsPane);
f.pack ();
f.show ();
}
catch (Exception e)
{
System.out.println ("Error: " + e.getMessage ());
System.exit (0);
}
}
}