public static void main(String[] args) throws IOException, PrinterException {
// Get the PrinterJob object that coordinates everything
PrinterJob job = PrinterJob.getPrinterJob();
// Get the default page format, then ask the user to customize it
PageFormat format = job.pageDialog(job.defaultPage());
// Create our PageableText object, and tell the PrinterJob about it
job.setPageable(new PageableText(new File(args[0]), format));
// Ask the user to select a printer, etc., and if not canceled, print!