I want to create .prn file which can be printed on any printer.
This is the code which i am using to print txt file using java, but not able to print doc and pdf file through this code.
can any one help me to print doc as well as pdf file using java


----------------------------------------------------------------------

import java.io.*;

import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;

public class CreateFile {
public static void main(String[] args) throws IOException {
String inputFileName = "myfile.txt";
String outputFileName = "myfile.prn";

File file;
file = new File("myfile.prn");
if (!file.exists()) {
file.createNewFile();
System.out.println("New file \"myfile.prn\" has been created ");
}

FileReader inputFileReader = new FileReader(inputFileName);
FileWriter outputFileReader = new FileWriter(outputFileName);

BufferedReader inputStream = new BufferedReader(inputFileReader);
PrintWriter outputStream = new PrintWriter(outputFileReader);

outputStream
.println("+---------- Testing output to a file ----------+");
outputStream.println();

String inLine = null;

while ((inLine = inputStream.readLine()) != null) {
outputStream.println(inLine);
}

outputStream.println();
outputStream
.println("+---------- Testing output to a file ----------+");

outputStream.close();
inputStream.close();

try {

InputStream is = new BufferedInputStream(new FileInputStream(
"File_Path"));

// Find the default service
DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST;
// DocFlavor flavor = new DocFlavor("application/octet-stream","java.io.InputStream");
PrintService service = PrintServiceLookup
.lookupDefaultPrintService();
System.out.println(service.getName());

// Create the print job
DocPrintJob job = service.createPrintJob();

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

// Print it
job.print(nic, null);

// It is now safe to close the input stream
is.close();
} catch (PrintException e) {
} catch (IOException e) {
System.out.println("Failed");
}
}

}



HELP WILL GREATLY APPRECIATE