简体   繁体   中英

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. 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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