title: Java: printing file doesn't work
body: <p>I use Java 1.6 (JDK), Windows 7 and a virtual image printer driver.</p>
  
  <p>I try to print some documents. </p>
  
  <p>Here is my code </p>
  
  <pre><code>try {    
  
     System.out.println(" PrintServiceOverseer printFileToDefaultPrinter start "+ 
        fileName);            
  
     PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
  
     System.out.println(" default Printer " + printService.getName());
  
     FileInputStream inputStream = new FileInputStream(new File(fileName));  
  
     DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;   
  
     Doc printDoc = new SimpleDoc(inputStream, docFlavor, null);
  
     PrintRequestAttributeSet  pras = new HashPrintRequestAttributeSet();
     pras.add(new Copies(1));   
  
     DocPrintJob printJob = printService.createPrintJob();
  
     printJob.print(printDoc, pras);
  
     inputStream.close();    
  
     System.out.println(" PrintServiceOverseer printFileToDefaultPrinter end "); 
  } catch (Exception ex) {
          ex.printStackTrace();
  }
  </code></pre>
  
  <p>But it doesn't work. It prints nothing and no exception is thrown. The code compiles and runs smoothly, but there is no output.</p>
  
  <p>Can you give me some guidance?</p>