My Program Won't Print when its supposed to

I've been trying to get a program that will automatically print txt files just by running it. Here's what I've come up with so far:

import java.io.*;

import javax.print.*;

import javax.print.attribute.*;

import javax.print.attribute.standard.*;

import javax.print.event.*;

import java.awt.print.*;

import java.awt.*;

import java.awt.image.*;

import java.net.*;

import java.*;

import javax.*;

publicclass PrintTests8

{

publicstaticvoid main(String[] args)

{

try

{

// Open the text file

InputStream is =new BufferedInputStream(new FileInputStream("test.txt"));

// Find the default service

DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;

PrintService service = PrintServiceLookup.lookupDefaultPrintService();

// Create the print job

DocPrintJob job = service.createPrintJob();

Doc doc =new SimpleDoc(is, flavor,null);

// Print it

job.print(doc,null);

// It is now safe to close the input stream

is.close();

}

catch (PrintException e)

{

e.printStackTrace();

}

catch (IOException e)

{

e.printStackTrace();

}

}

}

This will print out the file, but the problem is that it will only print itwhen another job, printed using in the normal, Ctrl+P type way, is printed. I hope that I can get help from you guys on this.

[2731 byte] By [Relas_Bladeknighta] at [2007-11-27 6:50:01]
# 1
C'mon people, I'm watching my topic slide away here, and its very important to get this help. I'm begging here!
Relas_Bladeknighta at 2007-7-12 18:23:52 > top of Java-index,Java Essentials,Java Programming...
# 2
This is just a SWAG, so i warn you that as free advice, it is certainly worth what you pay for it, but would adding a "flush" method help any?
petes1234a at 2007-7-12 18:23:52 > top of Java-index,Java Essentials,Java Programming...
# 3
did you try other option in your DocFlavor like TEXT_PLAIN_HOST?and please be patient...
suparenoa at 2007-7-12 18:23:52 > top of Java-index,Java Essentials,Java Programming...
# 4
This error comes up:sun.print.PrintJobFlavorException: invalid flavorat sun.print.Win32PrintJob.print(Win32PrintJob.java:327)at PrintTests8.main(PrintTests8.java:42)And sorry for being impatient.
Relas_Bladeknighta at 2007-7-12 18:23:52 > top of Java-index,Java Essentials,Java Programming...