[英]How can I programmatically set a source folder in Eclipse?
I need to create small files to save basic information. 我需要创建小文件来保存基本信息。 I can't read and write from the files once my project is exported as a JAR, so I created a folder to store the files outside of the src folder.
将项目导出为JAR后,我无法从文件中读取和写入,因此我创建了一个文件夹来存储src文件夹之外的文件。 This only works if I set the external folder to be a source folder.
这仅在我将外部文件夹设置为源文件夹时才有效。
This is the code where I create the folder 这是我创建文件夹的代码
File f = new File("Characters");
try{
if(f.mkdir()) {
System.out.println("Directory created");
} else {
System.out.println("Directory not created");
}
} catch(Exception e){
e.printStackTrace();
}
How can I programmatically set this folder to be a source folder? 如何以编程方式将此文件夹设置为源文件夹?
I hope this is specific enough. 我希望这足够具体。
These sound more like resource files rather then source files which require compiling. 这些听起来更像是资源文件,而不是需要编译的源文件。
Why not put them in a resource directory and load them when needed? 为什么不将它们放在资源目录中并在需要时加载它们?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.