简体   繁体   English

如何在Eclipse中以编程方式设置源文件夹?

[英]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.

相关问题 如何使用Gradle将文件夹设置为Eclipse中的源文件夹? - How do I set a folder as a Source Folder in Eclipse with Gradle? 如何将源文件夹更改为 Eclipse 中的测试源文件夹 - How can can I change a source folder to a test source folder in in Eclipse 是否可以将Eclipse中的源文件夹导入Flash Builder? - Can I import a source folder from Eclipse into Flash Builder? 如何让Eclipse将.class文件存储在我存储.java源文件的Project文件夹之外的文件夹中? - How can I get Eclipse to store .class files in a folder outside the Project folder where I store the .java source files? 如果在iTunes上以编程方式设置Itunes:Keep iTunes Folder Organized,我该怎么办? - How can I work out if Itunes:Keep iTunes Folder Organized is set programmatically on Windows 如何在eclipse中的源文件夹下创建文件夹? - how to create folder under source folder in eclipse? 如何从文件夹导入Eclipse - How can I import from a folder into Eclipse Eclipse:如何在运行配置中从lib文件夹设置插件? - Eclipse : How can I set plug-ins from lib folder in run configuration? 如何以编程方式使用“dp”设置边距? - How Can I Set Margin with 'dp' programmatically? 如何以编程方式设置 ViewPager layoutParams? - How can I set ViewPager layoutParams programmatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM