i have class which prints file. But i have refilled cartridge which sends out empty cartridge error when i manually print so i can press ok and continue. Here while printing through this class it aborts printing and gives message printing failed. how can i ignore cartridge empty error?
import javax.print.*;
import javax.print.attribute.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.io.*;
public class Printing {
public void print(String filename) throws Exception
{
HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; // MY FILE IS .txt TYPE
PrintService printService[] =
PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService =
PrintServiceLookup.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200,
printService, defaultService, flavor, pras);
if (service != null) {
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
try {
// ServiceUI.setLookAndFeel("com.sun.java.swing.plaf. windows.WindowsLookAndFeel");
} catch (Exception e) {
JFrame frame=new JFrame();
JOptionPane.showMessageDialog(frame,e.getMessage() , "ERROR",JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
Thread.sleep(10000);
}
//System.exit(0);
}
}