I am now desperate please help!!!!

This printing stuff is doing my head in please help
Here is my code I don't seem to be able to identify a printer at all. Can someone shed some light on this for me.!!
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
import javax.print.ServiceUI.*;
public class PrintFile {
//     public static void main(String args[]) {
//          PrintFile pf = new PrintFile();
//          System.out.println("Inside sorting printing document");
     public void PrintFile() {
          FileInputStream fis = null;
          try
          fis = new FileInputStream("logfile.txt");
          catch(FileNotFoundException ffne)
          if (fis == null)
               return;
          System.out.println("Inside sorting printing document");
          DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
          Doc doc = new SimpleDoc(fis, flavor, null);
          PrintRequestAttributeSet aset =
               new HashPrintRequestAttributeSet();
     //     aset.add(MediaSizeName.ISO_A4);
          aset.add(new Copies(1));
//          aset.add(Sides.ONE_SIDED);
     //     aset.add(Finishings.STAPLE);
          /* locate a print service that can handle it */
          PrintService[] pservices =
               PrintServiceLookup.lookupPrintServices(flavor,aset);
          if (pservices.length > 0) {
               System.out.println("selected printer " + pservices[0].getName());
               /* create a print job for the chosen service */
          DocPrintJob pj = pservices[0].createPrintJob();
               try {
                    /* print the doc as specified */
                    pj.print(doc, aset);
                    fis.close();
               } catch (PrintException e) {
                    System.err.println(e);
               catch (IOException ioe)
          else
               System.out.println("Something not right here");
}

i'm not sure why your code don't work but i see you have lots of //
anything behind // is a comment right ?
is lines 10-14 supost to be comments ?
ant

Similar Messages

Maybe you are looking for

  • Acrobat not working

    I just downloaded Creative Suite 6 Design and Web Premium for Windows and the Adobe Acrobat component isn't working. It doesn't open by itself or to open a PDF. InDesign and Illustrator are working fine, so I'm not sure why Acrobat specifically isn't

  • SetInterval and XML Load Problem

    Hello, I 'm having the simple problem of making sure the XML is loaded before beginning the Interval sequence. Therefore it is missing some of the XML data when loading. See example: http://alt.coxnewsweb.com/statesman/img/advertising/_jacob/Site1/pr

  • Call HEADER value into ITEM level in mapping

    HI, my structure is as below: H I I I P H I I P P H I I I I I P I have created a sequence in DB and retriving the value from DB using lookup for the header level(H) for feild ID.by using the code:    //write your code here    //write your code here S

  • MP boots to OS X Utilities

    My Mac Pro boots to Mac OS X Utilities, the Lion installer. I have my internal drive selected as startup disc, but can't get it to boot to that.

  • HT5625 how do i create apple id with my iphone 5s

    How can i transfer my contact from blackberry to my iphone 5s?