jsp页面中的applet能否调用本机的可执行文件? 想让jsp页面中的applet调用本机的可执行文件,而不是服务器上面的这个文件,应该如何实现那? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 同样的问题被我遇到,在IDE中调试applet时是可以调用本地可执行程序的,但将其嵌入到html页面终究不能调用了,郁闷啊!不知搂主解决了没有? JAVA的网站上有例子,不过我还没看明白,我发给你看看import java.awt.*;import java.io.*;import java.lang.*;import java.applet.*;public class writeFile extends Applet { String myFile = "/tmp/foo"; File f = new File(myFile); DataOutputStream dos; public void init() { String osname = System.getProperty("os.name"); if (osname.indexOf("Windows") != -1) { myFile="tmpfoo"; } } public void paint(Graphics g) { try { dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128)); dos.writeChars("Cats can hypnotize you when you least expect it\n"); dos.flush(); g.drawString("Successfully wrote to the file named " + myFile + " -- go take a look at it!", 10, 10); String name = System.getProperty("user.name"); g.drawString("And, successfully got user.name ..." + name, 10, 30); } catch (SecurityException e) { g.drawString("writeFile: caught security exception", 10, 10); } catch (IOException ioe) { g.drawString("writeFile: caught i/o exception", 10, 10); } }}这个是可以写本地文件。 好象applet 有个沙盒技术,,,不允许读写本地文件的,除非你配置安全权限 不要配置吧,把你写的class 先打包成JAR文件,在用KEYTOOL 生成一个密钥,再对JAR文件进行签名就可以了,, Quartz作业调度 学了半年,这么简单的I/O题不会。。 怎样让控件获得焦点啊? jar双击没有反应? 菜鸟求解Jdbc中如何取数组中的数据来建表和写入数据呢? 散分 用Properties 读取文件怎么读取中文阿???? 如何用java 实现在html上使用鼠标右键? 伤脑筋问题 各位大虾:帮帮忙,Socket问题呀 谁能讲讲flush执行失败的原因是什么啊! 把某个服务器短运行的jar反编译过来的源码(大概有上百个文件),经过自己的修改后打jar包能否和原来的jar一样能正常运行? 今天揭帖.
不知搂主解决了没有?
import java.awt.*;
import java.io.*;
import java.lang.*;
import java.applet.*;public class writeFile extends Applet {
String myFile = "/tmp/foo";
File f = new File(myFile);
DataOutputStream dos; public void init() {
String osname = System.getProperty("os.name");
if (osname.indexOf("Windows") != -1) {
myFile="tmpfoo";
}
} public void paint(Graphics g) {
try {
dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
dos.writeChars("Cats can hypnotize you when you least expect it\n");
dos.flush();
g.drawString("Successfully wrote to the file named " + myFile + " -- go take a look at it!", 10, 10); String name = System.getProperty("user.name");
g.drawString("And, successfully got user.name ..." + name, 10, 30);
}
catch (SecurityException e) {
g.drawString("writeFile: caught security exception", 10, 10);
}
catch (IOException ioe) {
g.drawString("writeFile: caught i/o exception", 10, 10);
}
}
}
这个是可以写本地文件。
除非你配置安全权限