/* Listing3504.java */

import java.awt.*;
import java.awt.Desktop.Action;
import java.io.*;

public class Listing3504
{
  public static void main(String[] args) throws IOException
  {
    Desktop d;
    if (Desktop.isDesktopSupported()) {
      d = Desktop.getDesktop();
      
      if (d.isSupported(Action.PRINT)) {
        File file = new File(args[0]);
        if (file.exists()) {
          d.print(file);
        }
        else {
          throw new IllegalStateException(
          file + " existiert nicht");
        }
      }
      else {
        throw new IllegalStateException(
        "Drucken wird nicht unterstützt");
      }
    }
    else {
      throw new IllegalStateException(
      "Desktop wird nicht unterstützt");
    }
  }
}