这是JAVA~~~~~~~~你自己看一下JDK吧FileInputStream(String name)
Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.
Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.
解决方案 »
- onmouseover事件后 都是悬浮在右边 怎么悬浮在左边呢
- 请教网页不同区域展示不同鼠标指针形状的实现方法?
- 求一简单替换字符串内容的正则表达式
- 高分求,在线等:如何取得td,li等子元素的绝对位置?
- [求助] JAVASCRIPT 改变页面输入框属性后的后退前进问题
- 请问在JS里怎样可以实现把一个网页另存为,另存时名字是在程序里给的,路径也是在程序里给的。 ——心急人上,在线等待
- 如何退出自定义的JavaScript函数!!???
- 请教高手一个问题,在线给分!
- 我这段代码邪了门了,除了上边的现象外,有时调用控件的方法是对的,但有时又不对,真是见了鬼,哪位大侠帮帮我!!!!!!!!!
- 关于在页面嵌入新页面导致新页面的$(document).ready(fn) 方法被执行两次的问题
- JS里判断长度问题,很奇怪,为什么总不对?
- 我用swithc语句,为什么不行呀,它会把case后的全执行一次。
import java.awt.Graphics;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.io.*;
import java.awt.Image;
import java.awt.MediaTracker;public class PrintFileTest extends Applet {
String imageFile;
String imageFile1;
Image image;
Image image1;
Image img;
public void init() {
imageFile = getParameter("picture");
imageFile1 = getParameter("picture1"); image = getImage(getDocumentBase(),imageFile); image1 = getImage(getDocumentBase(),imageFile1); prepareImage(image,this);
prepareImage(image1,this); MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image,0);
tracker.addImage(image1,0); try{
tracker.wait(0);
}catch(Exception ignore){ }
} public void start() {
printMap();
} public void stop() {
// printMap();
} public void destroy() { }
public void paint(Graphics g) {
g.drawImage(image1,0,0,this);
} public void printMap(){
String filename = imageFile;
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();
}
}
}
}
<html>
<head>
<title>test applet</title>
</head>
<body>
<br>
<applet
code = "PrintFileTest.class"
archive="print.jar"
name = "hello"
width = "500"
height = "400"
hspace = "0"
vspace = "0"
align = "center"
>
<param name="picture" value="0519/666.jpg">//用来打印的
<param name="picture1" value="0519/666.jpg"">//用来显示的
</applet>
</body>
</html>
这是很完整的程序! PrintFileTest.class 和HTML文件放在./文件夹下面,而666.jpg放在./0519下面.
当运行这个*.html文件时上面可以显示666.jpg文件,可是不能把这个文件打印出来
当你把<param name="picture" value="0519/666.jpg">改为<param name="picture" value="D:/./0519/666.jpg">时就可以打印出来!
大家发表意见吧!!!数字签名我做完了!谢谢指点