How to get the files in the target/xxx generated by idea compilation

  • directory structure

  • pom

  • target

target

if you do not configure the build location under the resource folder, the test.toml is in target/classes, with the .class file

public class ReadToml {

    public static void main(String[] args) {
        String fileName = "/test.toml";
        File file = new File(ReadToml.class.getResource(fileName).getFile());
        //Toml toml = new Toml().read(file);
    }
}

read it in the way above, and get the path of test.toml
now that build is configured, how can the file in the resources folder get its URL -!

Mar.03,2021

  • create a new directory under resources, such as conf, test.toml and put it under conf
  • you don't need to specify that targetPath, is in the root directory by default
 <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.toml</include>
                </includes>
            </resource>
        </resources>
    </build>
  • in the end, under target, the class files should all be under class/com, and the resource files should be under targate/classes. So String fileName = "/ conf/test.toml" is fine
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b380e7-34492.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b380e7-34492.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?