appletviewer运行ok浏览器不行

时间:2012-09-08 05:13:36

标签: file-uri appletviewer

appletviewer正确显示如果在jar文件中的类中有以下表达式:

File objectFile = new File("configurationfile.dat");

使用浏览器运行时出错。我改为

File objectFile = new File("\\\\mypc:8080/mymavenapp","configurationfile.dat");

并且成功相同。使用appletviewer运行DOS窗口会显示以下消息:

\\mypc:8080\mymavenapp\configurationfile.dat (No se ha encontrado la ruta de acceso de la red)

1 个答案:

答案 0 :(得分:1)

我将该文件放在该类的同一个包中并更改了以下内容:

objectFile = new File((new URI("file:C:/users/user/documents/NetBeansProjects/mavenHMI2/archivConfHMI.dat")));
                    fileInputStream = new FileInputStream(objectFile);
            objectInputStream = new ObjectInputStream(fileInputStream);

by:

InputStream is = getClass().getResourceAsStream("archivConfHMI.dat"); 
                    objectInputStream = new ObjectInputStream(is);