从签名的applet将图像保存在服务器上

时间:2011-12-14 09:52:20

标签: java image applet

在我签名的applet中,我有一个Image对象,现在我想通过创建一个新文件将此Image保存在getCodebase()。我用:

File file2=new File(getCodeBase()+"newFile.gif");
file2.createNewFile();
ImageIO.write(myImage, "png", file2);

要创建新文件,然后ImageIO在此目的地写入文件,但会出现以下错误。

http://192.168.1.119:96/res/applet/newFile.gif
pgraph.sendImageToServer... exceptionThe filename, directory name, or volume label syntax is incorrect
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)

如何从已签名的小程序中保存服务器上的图像?

1 个答案:

答案 0 :(得分:1)

  1. 如果applet建立了File对象,则File将指向最终用户PC的文件系统上的某个位置。它永远不会指向服务器。
  2. 对于要在服务器上保存任何内容的小程序,它需要将资源的字节返回到服务器上用于保存图像的脚本。
  3. 如果小程序“打电话回家”到自己的服务器以保存图像,则无需进行数字签名。