• Post Reply Bookmark Topic Watch Topic
  • New Topic

priting utf-8 text using java x.print  RSS feed

suni nitu
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Iam trying to print UTF-8 text file using the follwing programme

import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class BasicPrint1 {
public static void main(String[] args) {
try {

String line;
File file = null;
file = new File("exutf8.txt");
HashDocAttributeSet hattr=null;
DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
InputStreamReader in = new InputStreamReader(new FileInputStream(file),"UTF-8");
DocPrintJob job = service.createPrintJob();
Doc doc = new SimpleDoc(new FileInputStream(file), flavor, null);

} catch (Exception e) {


When I am trying to execute this programme its throwing the following exception

java.lang.IllegalArgumentException: data is not of declared type
at javax.print.SimpleDoc.<init>(Unknown Source)
at BasicPrint.main(BasicPrint.java:58)

Please provide the solution ASAP

Thanks in advance
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!