是什么原因呢(内存??)
大家看看这段程序
import java.applet.Applet;
import java.awt.Graphics;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.io.*;
public class PrintFileTest extends Applet {
private String TMP_FILE="C:\\pics\\map20.jpg";
public void init() {
}
public void start() {
printMap();
}
public void stop() {
}
public void destroy() {
}
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
// g.drawRect(0, 0, size().width - 1, size().height - 1);
//Draw the current string inside the rectangle.
// g.drawString(buffer.toString(), 5, 15);
}
public void printMap(){
String filename = TMP_FILE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);
if (service != null) {
try
{
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
// PageFormat format = job.pageDialog(attributes);
job.print(doc, pras);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
这个段程序为什么当图片很大的时侯就出现内存溢出(outofmemoryerror)???appletviewer -Xmx512m -Xms512m PrintFileTest 这样就可以解决!
请问还有没有其他的方法!因为这是在IE上运行的程序,不应该在DOS下面运行!
用代码在程序里面入如何实现???我需要看哪方面的资料呢!!请大家多多指点:)
小弟在这里先谢谢了。。。。