简体   繁体   English

如何将文件从另一个非Java程序输出到Java jar文件的resources文件夹中

[英]How to output a file from another non java programme into the resources folder of a java jar file

I have an R script that outputs html and dumps it in a directory of my choosing. 我有一个R脚本,可以输出html并将其转储到我选择的目录中。 I also have a java Swing application with a WebView component that allows me to see the html from within the Swing application. 我还有一个带有WebView组件的Java Swing应用程序,它使我能够从Swing应用程序中查看html。

This works OK on most computers but because the outputted html contains a base64 image, for some reason the image cannot be viewed from the Swing WebViewer on certain operating systems(although the rest of the html can-I can see the images on my mac but not on Windows 2003). 这在大多数计算机上都可以正常运行,但是由于输出的html包含base64图像,由于某些原因,在某些操作系统上无法从Swing WebViewer查看该图像(尽管html的其余部分可以,但我可以在Mac上看到这些图像,但是不适用于Windows 2003)。

I think this is a problem relating to the security of a java programme accessing resources outside of the programme that maybe permissions are not set up for or something. 我认为这是一个与Java程序的安全性有关的问题,该Java程序访问程序外部的资源(可能未设置权限)。

To simplify things I want to dump the html in resources that are local to the Swing application (ie in a resources folder) that would be contained within the deployed jar. 为简化起见,我想将html转储到Swing应用程序本地资源(即资源文件夹中)中,该资源将包含在已部署的jar中。 How can I do this? 我怎样才能做到这一点? Is this even possible? 这有可能吗?

Yes, this possible. 是的,这可能。 This way you have to 这样你必须

  • Script: inserts the content within the jar file (root folder within the jar) 脚本:将内容插入jar文件(jar中的根文件夹)中
  • Swing: program has to be (re-)started 摇摆:必须(重新)启动程序
  • Swing: read file from within jar (eg with getResourceAsStream - method of the class loader) 摆动:从jar中读取文件(例如,使用getResourceAsStream-类加载器的方法)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM