0

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

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)
4

1 回答 1

1

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

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

经过:

InputStream is = getClass().getResourceAsStream("archivConfHMI.dat"); 
                    objectInputStream = new ObjectInputStream(is);          
于 2012-09-12T14:05:44.960 回答