简体   繁体   English

如何访问Netbeans(Java)中的资源文件?

[英]How to access resource files in Netbeans (Java)?

There are two requirements, 有两个要求,

  • Locate and Run a .m (Octave script) using Java 使用Java找到并运行.m(Octave脚本)
  • Take the output and use it in the program. 获取输出并在程序中使用它。

This is how my files are 这就是我的文件

I tried putting them in different folders and it didn't work. 我尝试将它们放在不同的文件夹中,但它不起作用。
文件结构

This is how I want to use them. 这就是我想要使用它们的方式。
使用文件的代码

How do I access them in Netbeans IDE 8.2? 如何在Netbeans IDE 8.2中访问它们?


Edit for Clarification: 编辑澄清:
The presumed duplicate doesn't solve my problem. 假定的副本不能解决我的问题。 It tell us how to import an image. 它告诉我们如何导入图像。 What I am doing here is running a script directly which is stored somewhere in my project files. 我在这里做的是直接运行一个脚本,它存储在我的项目文件中。

As per the netbeans directory project structure, you need to create one resources directory. 根据netbeans目录项目结构,您需要创建一个资源目录。 Then put your files there in resource directory. 然后将您的文件放在资源目录中。

Please update your code like below. 请更新您的代码,如下所示。

Put your file under /resources/, then use it like below. 将您的文件放在/ resources /下,然后像下面一样使用它。

ProcessBuilder pb= new ProcessBuilder("resources/ProcessImg.m");
Path data_file = Paths.get("resources/data.txt")

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

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