Write to a local file through JNLP

。_饼干妹妹 提交于 2019-12-07 02:24:31

The JNLP also needs to specify:

<security>
    <all-permissions/>
</security>

See the JNLP File Syntax for details.


I would generally use the FileSaveService as detailed in Tom's answer, but this sounds more like a situation where the 'file' could be a default properties file for configuring the app. The save service is not well suited to that, since the app. has no way to know where the file is stored, or how to access it later. For security reasons, the FileContents object that is provided in place of a File has no methods that return the path.

In that case, extract the details of the config. file & store them using the PersistenceService of the JNLP API. Here is a demo. of the PersistenceService. This service is also available to sand-boxed apps. (no code signing voodoo).

You can save a file, with user interaction, from an unsigned WebStart application using javax.jnlp.FileSaveService.

Possibly a piece you are missing is marking the aplication as secure in the JNLP file. However, writing a secure application is a little tricky, and I wouldn't recommend it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!